Skip to content

Instantly share code, notes, and snippets.

@merong
Created June 6, 2020 04:39
Show Gist options
  • Save merong/89dd4a74d29c7c57e0ee739301681fbc to your computer and use it in GitHub Desktop.
Save merong/89dd4a74d29c7c57e0ee739301681fbc to your computer and use it in GitHub Desktop.
nginx 리버스 프록시를 사용하여 ws 를 wss로 전환 처리
# nginx에서 웹소켓 reverse proxy 설정은 아래내용을 참조하세요.
# https://www.joinc.co.kr/w/man/12/nginx/wsproxy
#설정 예제
#아래와 같이 설정한 경우 wss주소는
# ws://호스트도메인:9000/ 으로 채팅서버를 실행하였다면,
# wss://호스트도메인:8080/ 이 됩니다.
# 운용하는 채팅서버 아이피가 다른 경우 proxy_pass에 아이피를 지정하시면 됩니다.
server {
listen 8088 ssl;
server_name your_domain.com;
### ssl 인증서 관련 코드 ####
#ssl_certificate ...;
#ssl_certificate_key ...;
#....
location / {
proxy_pass http://127.0.0.1:9000/; #실제 채팅서버의 아이피와 포트
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Accept-Encoding "";
}
}
@reikop
Copy link

reikop commented Apr 26, 2021

감사합니다 ;)

@javamon1174
Copy link

최고에여!

@dntjr031
Copy link

감사합니다!👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment