[nginx]配置nginx支持websocket解决返回400错误问题
2023-02-18 15:37:11 时间
当nginx里没有配置支持webocket时 , 但是已经配置了域名 比如:ws://gofly.sopans.com/ws_visitor
直接js连会返回400的错误
需要在nginx location 块下增加这三个header头 , 把http连接升级为websocket连接
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
比如我的开源客服gofly中
server{ listen 80; server_name gofly.sopans.com; access_log /var/log/nginx/gofly.sopans.com.access.log main; client_max_body_size 10M; location /static { root /var/www/html/go-fly; } location / { proxy_pass http://127.0.0.1:8081; proxy_http_version 1.1; proxy_set_header X-Real-IP $remote_addr; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; } }
相关文章
- Redis分布式锁的10个坑
- 如何解决 Redis 数据倾斜、热点等问题
- 免费给自己的网站加 HTTPS
- iterm2 快捷键(转载)
- Too many authentication failures for xxxx_username
- peewee insert 数据时报错:'buffer' object has no attribute 'translate'
- virtualenv 虚拟环境报错:setuptools pip wheel failed with error code 1
- supervisor 安装、配置、常用命令
- _ssl.c:510: error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure
- [MySQL]支持 emoji(字符集问题)
- [MySQL]长连接和短链接(转载)
- 解决 InsecurePlatformWarning: A true SSLContext object is not available.
- Mac总是自动启动脚本
- Max retries exceeded with url
- brew tap homebrew-science fails
- 持续集成是什么?(转载)
- [编辑器]vim常用操作
- Mac下中文输入法突然没了选字框
- install dm.xmlsec.binding 失败
- [MySQL]创建数据库以及设置编码