socket 서버 기동시 nginx 설정 방법

Jinseok Lee·2021년 9월 29일

사연

로컬에서 개발중이던 소켓서버를 실제 서버에 띄우려고 하니 nginx 쪽에서 설정을 어떻게 해주어야 할지 몰라서 고민하고 있었다. 물론 클라이언트 쪽에서 소켓서버 쪽으로 연결도 계속 안되고 있었다.

해결

server {
        listen 8080;
        server_name chatting-server.my-domain.com;

        location / {
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header Host $host;
                proxy_pass http://localhost:7505/;
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection "upgrade";
        }
}

구글에 찾아보니 위와 같이 설정을 해줘야 한다고 한다. 각각의 자세한 내용까지는 모르겠다.

참조

profile
전 위메프, 이직준비중

0개의 댓글