Skip to content
Snippets Groups Projects
Commit 50b659fe authored by Emmanuel Bruno's avatar Emmanuel Bruno
Browse files

adds ws reverse proxy.

parent aae22b88
No related branches found
No related tags found
No related merge requests found
...@@ -40,10 +40,13 @@ curl --cacert localhost.pem \ ...@@ -40,10 +40,13 @@ curl --cacert localhost.pem \
Avec un reverse proxy : Avec un reverse proxy :
``` ```
echo quit | openssl s_client -showcerts \ echo quit | openssl s_client -showcerts \
-servername localhost -connect localhost:8888 >! nginx.pem -servername localhost -connect localhost:8888 >! localhost.pem
curl --cacert localhost.pem \ curl --cacert localhost.pem \
https://localhost:8181/restApp-1.0-SNAPSHOT/resources/sample/persons/843c8236-6c6b-450e-9aa3-211a9b897403 https://localhost:8181/restApp-1.0-SNAPSHOT/resources/sample/persons/843c8236-6c6b-450e-9aa3-211a9b897403
keytool -noprompt -storepass storepass -import \
-trustcacerts -alias mycert -file localhost.pem -keystore mycert-pub.jks
``` ```
......
...@@ -2,8 +2,8 @@ FROM nginx:1.20.2-alpine ...@@ -2,8 +2,8 @@ FROM nginx:1.20.2-alpine
RUN apk add openssl RUN apk add openssl
RUN openssl req -x509 -nodes \ RUN openssl req -x509 -nodes \
-days 365 \ -days 365 \
-subj "/C=CA/ST=QC/O=Company, Inc./CN=mydomain.com" \ -subj "/C=CA/ST=QC/O=Company, Inc./CN=localhost" \
-addext "subjectAltName=DNS:mydomain.com" \ -addext "subjectAltName=DNS:localhost" \
-newkey rsa:2048 \ -newkey rsa:2048 \
-keyout /etc/ssl/private/nginx-selfsigned.key \ -keyout /etc/ssl/private/nginx-selfsigned.key \
-out /etc/ssl/certs/nginx-selfsigned.crt; -out /etc/ssl/certs/nginx-selfsigned.crt;
\ No newline at end of file
...@@ -10,6 +10,13 @@ http { ...@@ -10,6 +10,13 @@ http {
ssl_certificate /etc/ssl/certs/nginx-selfsigned.crt; ssl_certificate /etc/ssl/certs/nginx-selfsigned.crt;
ssl_certificate_key /etc/ssl/private/nginx-selfsigned.key; ssl_certificate_key /etc/ssl/private/nginx-selfsigned.key;
location /wsapp/ {
proxy_pass http://jakartaEE:8686;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
}
location / { location / {
proxy_pass http://jakartaEE:8080; proxy_pass http://jakartaEE:8080;
} }
......
...@@ -24,6 +24,7 @@ public class WSServer { ...@@ -24,6 +24,7 @@ public class WSServer {
@SpokenLanguage(SpokenLanguage.Language.ENGLISH) @SpokenLanguage(SpokenLanguage.Language.ENGLISH)
Hello hello; Hello hello;
@Inject @Inject
MainDAO dao1; MainDAO dao1;
...@@ -36,8 +37,8 @@ public class WSServer { ...@@ -36,8 +37,8 @@ public class WSServer {
} }
@OnMessage @OnMessage
public void onMessage(Session session, public void onMessage(String message, Session session
String message) throws IOException { ) throws IOException {
session.getBasicRemote().sendText("Echo :" + message); session.getBasicRemote().sendText("Echo :" + message);
} }
} }
......
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_2_0.xsd"
bean-discovery-mode="all">
</beans>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_2_0.xsd"
bean-discovery-mode="all">
</beans>
\ No newline at end of file
...@@ -41,8 +41,10 @@ public class WsClient { ...@@ -41,8 +41,10 @@ public class WsClient {
public static void main(String[] args) { public static void main(String[] args) {
try { try {
URI uri = new URI("ws://localhost:8686/wsApp-1.0-SNAPSHOT/hellows");
final WsClient clientEndPoint = new WsClient(new URI("wss://localhost:8686/wsApp-1.0-SNAPSHOT/hellows")); //URI uri = new URI("wss://localhost:8888/wsapp/wsApp-1.0-SNAPSHOT/hellows");
log.info("Connecting to "+uri);
final WsClient clientEndPoint = new WsClient(uri);
clientEndPoint.sendMessage("Hello 1 !"); clientEndPoint.sendMessage("Hello 1 !");
Thread.sleep(5000); Thread.sleep(5000);
clientEndPoint.sendMessage("Hello 2 !"); clientEndPoint.sendMessage("Hello 2 !");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment