nginx反向代理及支持websocket

2018-05-11  本文已影响0人  Ppnn13Yu

找到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 ~ / {

}里面。

上一篇 下一篇

猜你喜欢

热点阅读