-
Notifications
You must be signed in to change notification settings - Fork 8
fix: Nginx가 WebSocket Handshake 요청을 올바르게 처리하도록 #481
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
5a0d496
d1fcce6
a846f30
4875df9
86e4b52
628e7a6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| server { | ||
| listen 80; | ||
| server_name api.stage.solid-connection.com; | ||
|
|
||
| # http를 사용하는 경우 주석 해제 | ||
| # location / { | ||
|
|
@@ -17,9 +18,10 @@ server { | |
|
|
||
| server { | ||
| listen 443 ssl; | ||
| server_name api.stage.solid-connection.com; | ||
|
|
||
| ssl_certificate /etc/letsencrypt/live/api.solid-connection.com/fullchain.pem; | ||
| ssl_certificate_key /etc/letsencrypt/live/api.solid-connection.com/privkey.pem; | ||
| ssl_certificate /etc/letsencrypt/live/api.stage.solid-connection.com/fullchain.pem; | ||
| ssl_certificate_key /etc/letsencrypt/live/api.stage.solid-connection.com/privkey.pem; | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. stage 서버이고, 실제로 stage 이름을 가지는 디렉터리 및 인증서가 존재합니다. |
||
| client_max_body_size 10M; | ||
|
|
||
| ssl_protocols TLSv1.2 TLSv1.3; | ||
|
|
@@ -31,10 +33,13 @@ server { | |
| ssl_stapling_verify on; | ||
|
|
||
| location / { | ||
| proxy_pass http://solid-connection-server:8080; | ||
| proxy_pass http://localhost:8080; | ||
whqtker marked this conversation as resolved.
Show resolved
Hide resolved
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| proxy_set_header Host $host; | ||
| proxy_set_header X-Real-IP $remote_addr; | ||
| proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
| proxy_set_header X-Forwarded-Proto $scheme; | ||
| proxy_http_version 1.1; | ||
| proxy_set_header Upgrade $http_upgrade; | ||
| proxy_set_header Connection "upgrade"; | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. WebSocket Handshake 관련 설정입니다 |
||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| server { | ||
| listen 80; | ||
| server_name api.solid-connection.com; | ||
|
|
||
| location / { | ||
| return 301 https://$host$request_uri; | ||
| } | ||
| } | ||
|
|
||
| server { | ||
| listen 443 ssl; | ||
| server_name api.solid-connection.com; | ||
|
|
||
| ssl_certificate /etc/letsencrypt/live/api.solid-connection.com/fullchain.pem; | ||
| ssl_certificate_key /etc/letsencrypt/live/api.solid-connection.com/privkey.pem; | ||
| client_max_body_size 10M; | ||
|
|
||
| ssl_protocols TLSv1.2 TLSv1.3; | ||
| ssl_prefer_server_ciphers on; # 클라이언트 보다 서버의 암호화 알고리즘을 우선하도록 설정 | ||
| ssl_ciphers "ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256"; | ||
| ssl_session_cache shared:SSL:10m; # SSL 세션 캐시 설정 | ||
| ssl_session_timeout 10m; | ||
| ssl_stapling on; # OCSP 스테이플링 활성화 | ||
| ssl_stapling_verify on; | ||
|
|
||
| location / { | ||
| proxy_pass http://127.0.0.1:8080; | ||
| proxy_set_header Host $host; | ||
| proxy_set_header X-Real-IP $remote_addr; | ||
| proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
| proxy_set_header X-Forwarded-Proto $scheme; | ||
| proxy_http_version 1.1; | ||
| proxy_set_header Upgrade $http_upgrade; | ||
| proxy_set_header Connection "upgrade"; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,8 +30,8 @@ | |
| import org.springframework.web.socket.sockjs.client.WebSocketTransport; | ||
|
|
||
| @TestContainerSpringBootTest | ||
| @DisplayName("WebSocket/STOMP 통합 테스트") | ||
| class WebSocketStompIntegrationTest { | ||
| @DisplayName("WebSocket Handshake 테스트") | ||
| class WebSocketHandshakeTest { | ||
|
|
||
| @LocalServerPort | ||
| private int port; | ||
|
|
@@ -47,7 +47,7 @@ class WebSocketStompIntegrationTest { | |
|
|
||
| @BeforeEach | ||
| void setUp() { | ||
| this.url = String.format("ws://localhost:%d/connect", port); | ||
| this.url = String.format("http://localhost:%d/connect", port); | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 웹소켓 핸드셰이크 시 ws가 아니라 https 프로토콜을 사용합니다. 단, SSL 관련 설정이 없기에, http로 임시로 변경합니다. |
||
| List<Transport> transports = List.of(new WebSocketTransport(new StandardWebSocketClient())); | ||
| this.stompClient = new WebSocketStompClient(new SockJsClient(transports)); | ||
| this.stompClient.setMessageConverter(new MappingJackson2MessageConverter()); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
인증서 관련 문제가 발생했어서 추가했습니다.