Linux运维实战:Nginx方向代理wss或ws

2022-07-06 20:50
130
0
   location ^~ /proxy
               {
                    proxy_pass http://ws服务器的ip:ws的端口;
                    proxy_http_version 1.1;
                    log_not_found off;
                    proxy_set_header Host $http_host;
                    #proxy_set_header Host $host:$server_port;

                    proxy_set_header X-Real-IP $remote_addr;
                    proxy_redirect off;
                    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                    proxy_set_header X-Forwarded-Proto $scheme;
                    proxy_set_header Upgrade $http_upgrade;
                    proxy_set_header Connection "upgrade";
                    proxy_connect_timeout 1000;
                    proxy_read_timeout 1000; #超时配置一定要
                    rewrite ^/proxy/ws服务器的ip:ws的端口/(.*)$ /$1 break;  #这里是去掉中间一节参数

               }

 

参考地址

[https://blog.csdn.net/m0_37814112/article/details/123737847](https://blog.csdn.net/m0_37814112/article/details/123737847)

全部评论