nginx反向代理及支持websocket

找到nginx.conf

server{

      listen 8081;

            server_name www.p2pfast.com;

      location / {

        proxy_pass http://localhost:8080/;

                }

      proxy_set_header X-Real-IP $remote_addr;

      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

      proxy_set_header Host $http_host;

      proxy_set_header Upgrade $http_upgrade;

      proxy_set_header Connection "upgrade";

    }


支持websocket把这两行配置加上就可以了

proxy_set_header Upgrade $http_upgrade;

proxy_set_header Connection "upgrade";

放在自己server里的location ~ / {

}里面。

你可能感兴趣的:(nginx反向代理及支持websocket)