From 8177cebf37fef253f9b1d029480bf854a22e7ded Mon Sep 17 00:00:00 2001 From: Dmori <83327857+Dimo-2562@users.noreply.github.com> Date: Wed, 25 Feb 2026 12:04:29 +0900 Subject: [PATCH] =?UTF-8?q?[debug/#479]=20Nginx=20WebSocket=20=EC=97=85?= =?UTF-8?q?=EA=B7=B8=EB=A0=88=EC=9D=B4=EB=93=9C=20=ED=97=A4=EB=8D=94=20?= =?UTF-8?q?=EB=88=84=EB=9D=BD=EC=9C=BC=EB=A1=9C=20SockJS=20JSONP=20?= =?UTF-8?q?=ED=8F=B4=EB=B0=B1=20=EA=B2=BD=EA=B3=A0=20=EB=B0=9C=EC=83=9D=20?= =?UTF-8?q?(#480)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * test: 테스트를 위해 잠시 배포 조건 변경 * debug: Nginx에서 웹소켓 헤더 업그레이드를 지원하지 않았던 문제를 해결 * chore: 테스트를 위해 잠시 바꿨던 배포 조건 변경 * chore: WebSocket 허용 경로에 staging 경로 추가 --- nginx/conf.d/prod.conf | 11 +++++++++++ nginx/conf.d/staging.conf | 11 +++++++++++ .../cockple/demo/global/config/WebSocketConfig.java | 2 +- 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/nginx/conf.d/prod.conf b/nginx/conf.d/prod.conf index 314b3e38..d44e6d45 100644 --- a/nginx/conf.d/prod.conf +++ b/nginx/conf.d/prod.conf @@ -2,6 +2,17 @@ server { listen 80; server_name cockple.store; + location /ws/ { + proxy_pass http://cockple-app:8080; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + 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 $http_x_forwarded_proto; + } + location / { proxy_pass http://cockple-app:8080; proxy_set_header Host $host; diff --git a/nginx/conf.d/staging.conf b/nginx/conf.d/staging.conf index 2a222c17..e050fc27 100644 --- a/nginx/conf.d/staging.conf +++ b/nginx/conf.d/staging.conf @@ -2,6 +2,17 @@ server { listen 80; server_name staging.cockple.store; + location /ws/ { + proxy_pass http://cockple-app-staging:8080; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + 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 $http_x_forwarded_proto; + } + location / { proxy_pass http://cockple-app-staging:8080; proxy_set_header Host $host; diff --git a/src/main/java/umc/cockple/demo/global/config/WebSocketConfig.java b/src/main/java/umc/cockple/demo/global/config/WebSocketConfig.java index 8efc432a..aea6747b 100644 --- a/src/main/java/umc/cockple/demo/global/config/WebSocketConfig.java +++ b/src/main/java/umc/cockple/demo/global/config/WebSocketConfig.java @@ -21,7 +21,7 @@ public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) { registry .addHandler(chatWebSocketHandler, "/ws/chats") .addInterceptors(jwtWebSocketAuthInterceptor) - .setAllowedOrigins("http://localhost:5173", "https://cockple.store", "https://cockple-fe.vercel.app/") + .setAllowedOrigins("http://localhost:5173", "https://cockple.store", "https://cockple-fe.vercel.app/", "https://staging.cockple.store") .withSockJS(); // 브라우저 호환성 } }