NodeJS

Nginx 사용시 웹소켓 에러 날때 해결방법 failed error during websocket handshake unexpected response code 400

Grand_J 2019. 5. 29. 13:30
반응형

\conf\nginx.conf 파일 오픈 

아래 proxy_http_version, proxy_set_header 부분 추가


# WebSocket connection to 'ws://localhost:8080/socket.io/?EIO=3&transport=websocket&sid=3uzcJLGrxo8cZq_gAAAD' failed: Error during WebSocket handshake: Unexpected response code: 400
        # 위 웹소켓 연결 에러로 proxy_http_version, proxy_set_header 옵션 추가 
        # proxy_http_version : WebSocket에 필요한 노드 백엔드와 통신 할 때 HTTP / 1.1을 사용하도록 지시 
        # proxy_set_header : WebSocket을 사용할 때 브라우저가 HTTP를 통해 시작하는 업그레이드 요청에 응답하도록 지시

        location / { 
            #root   html; 
            #index  index.html index.htm;             
            proxy_pass http://nodejs_server; 
            proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504; 
            proxy_http_version 1.1; 
            proxy_set_header Upgrade $http_upgrade; 
            proxy_set_header Connection "upgrade"; 
            proxy_set_header Host $host; 
        }

 

 

꿌!@$%#%^%$#$#$!ㄸ!@

반응형