Nginx反向代理

57次阅读
没有评论

Nginx 反向代理 WebScoket、ws、wss

location /chat/ {
    proxy_pass http://backend;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
}

结合rewrite重写路径

location /ws/ {
    rewrite ^/ws/(.*)$ /$1 break;
    proxy_pass http://backend;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "Upgrade";
    proxy_set_header Host $host;
}

正文完
 0
wujingquan
版权声明:本站原创文章,由 wujingquan 于2024-11-13发表,共计377字。
转载说明:Unless otherwise specified, all articles are published by cc-4.0 protocol. Please indicate the source of reprint.
评论(没有评论)