conf.d/app.conf를 변경해서 해결했다..
최종 코드 (24.10.25 11:49)
server{
listen 80;
listen 443 ssl;
server_name dp-union.site www.dp-union.site;
ssl_certificate /etc/letsencrypt/live/dp-union.site/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/dp-union.site/privkey.pem;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers on;
ssl_ciphers HIGH:!aNULL:!MD5;
if ($scheme = http) {
return 301 https://$host$request_uri;
}
location / {
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'Authorization, Content-Type, Refresh-Token';
add_header 'Access-Control-Expose-Headers' 'Authorization, Refresh-Token' always;
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Length' 0;
add_header 'Content-Type' 'text/plain charset=UTF-8';
return 204; # Preflight 요청은 204로 응답
}
proxy_pass http://localhost: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;
}
# 웹소켓 연결 허용
location /ws {
proxy_pass http://localhost:8080; # 웹소켓 처리 서버 주소 (포트 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 $scheme;
}
# CORS 설정
add_header 'Access-Control-Allow-Origin' '*' always;
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS' always;
add_header 'Access-Control-Allow-Headers' 'Authorization, Content-Type, Refresh-Token' always;
add_header 'Access-Control-Expose-Headers' 'Authorization, Refresh-Token' always;
}
Plain Text
복사
https://dp-union.site/health 여기로 요청하면 200 뜬다..~