nginx转发websocket配置
生活随笔
收集整理的這篇文章主要介紹了
nginx转发websocket配置
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
背景:啟動socket后,一般可以用ip進行直連,不過這樣會引發很多問題
解決方案:采用 域名+nginx轉發
nginx配置如下:
upstream swoole_http_server {server 127.0.0.1:9501; # 這里為websocket服務器地址 }server {listen 80;server_name xxx.phper520.cn; #這里填自個的域名location / {#轉發地址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 X-NginX-Proxy true;proxy_pass http://swoole_http_server;proxy_http_version 1.1;proxy_set_header Upgrade $http_upgrade;proxy_set_header Connection "upgrade";proxy_redirect off;} }總結
以上是生活随笔為你收集整理的nginx转发websocket配置的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 甘肃省基础地理信息数据大全(shp格式)
- 下一篇: Photoshop制作漂亮的圣诞树