解决 Nginx 400 Bad Request 问题(WebSocket)
400 Bad Request 是一种 HTTP 错误状态码。HTTP/1.1 对 400 Bad Request的定义主要是:
- 语义有误,当前请求无法被服务器理解
- 请求参数有误
- 丢包导致异常
Google 了一番,很多说是请求头或 cookie 过大引起的,调整 client_header_buffer_size 与 large_client_header_buffers 大小,但是并没有解决问题。经过排查发现 GET 请求的时候没有问题,POST 的时候就会返回 400 Bad Request 错误,最后发现是 websocket 配置成了全局 ,单独配置 websocket 的地址即可。
server {
listen 80;
# https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/linux-nginx?view=aspnetcore-2.2
location / {
proxy_pass http://localhost:5000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection keep-alive;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
# https://www.nginx.com/blog/websocket-nginx/
location /hqHub {
proxy_pass http://localhost:5000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
} server {
listen 8080;
location / {
proxy_pass http://127.0.0.1:6800/;
auth_basic "Restricted";
auth_basic_user_file /etc/nginx/conf.d/.htpasswd;
}
}
REFER:
http://nginx.org/en/docs/http/websocket.html
https://blog.csdn.net/zhuyiquan/article/details/78707577
https://xiaomingyang.com/2018/04/17/centos-nginx-error.html
解决 Nginx 400 Bad Request 问题(WebSocket)的更多相关文章
- 解决 nginx 出现 413 Request Entity Too Large 的问题
1.若nginx用所用的 php 请求解析服务是 fpm, 则检查 /etc/php5/fpm/php.ini 文件中的参数 upload_max_filesize = 20M post_max_si ...
- 解决nginx转发websocket报400错误
解决nginx转发websocket报400错误 说明 由于个人服务器上面有多个项目,配置了二级域名,需要对二级域名进行转发,在转发工作这快采取了大名鼎鼎的nginx.在这之前所有的项目运行转发都没问 ...
- nginx过一段时间出现400 Bad Request 错误的解决方法
tomcat整合nginx成功后,等访问一段时间后,会出现 Bad Request (Invalid Hostname)的错误, 因为是已经成功的配置,所以判定可能是哪里的限制设置有问题,最后在官方网 ...
- 网页出现400 Bad Request Request Header Or Cookie Too Large错误的解决方法
在开发项目过程中,突然遇到400 Bad Request Request Header Or Cookie Too Large的报错,我也是第一次出现这样的错误,感觉还是挺新奇的. 分析下出现错误的原 ...
- nginx转发成功报400 bad request,服务端未收到请求
nginx转发成功报400 bad request,服务端未收到请求 解决办法: upstream后面不要跟下划线 例如: upstream auth_service{ server 30.4.164 ...
- Apache rewrite 出现 400 Bad Request 的解决方法
<VirtualHost *:80 *:81> ServerAdmin deng5765@163.com DocumentRoot /active/www/ ...
- SpringMVC中出现" 400 Bad Request "错误(用@ResponseBody处理ajax传过来的json数据转成bean)的解决方法
最近angularjs post到后台 400一头雾水 没有任何错误. 最后发现好文,感谢作者 SpringMVC中出现" 400 Bad Request "错误(用@Respon ...
- nginx 出现413 Request Entity Too Large问题的解决方法
nginx 出现413 Request Entity Too Large问题的解决方法 使用php上传图片(大小1.9M),出现 nginx: 413 Request Entity Too Large ...
- Nginx出现“413 Request Entity Too Large”错误解决方法
Nginx出现“413 Request Entity Too Large”错误解决方法 2011-03-25 13:49:55| 分类: 默认分类 | 标签:413 request entit ...
随机推荐
- loadtxt函数
numpy.loadtxt numpy.loadtxt(fname, dtype=<type 'float'>, comments='#', delimiter=None, convert ...
- eclipse遇到启动报an error has occurred see the log file错
错误: 修改eclipse安装目录下比如D:\eclipse\configuration\.settings\org.eclipse.ui.ide.prefs, 删除 RECENT_WORKSPACE ...
- mac os ssh远程链接centos提示证书错误解决方法
下面是错误提示 IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY! Someone could be eavesdropping on you ...
- (PMP)解题技巧和典型题目分析(模拟一)
- yum安装常用工具命令
树状目录结构(tree) yum install tree 上传下载工具(rz和sz) yum install lrzsz -------------------------------------- ...
- python循环解压rar文件
python循环解压rar文件 C:. │ main.py │ ├─1_STL_算法简介 │ STL_算法简介.rar │ └─2_STL_算法_填充新值 STL_算法_填充新值.rar 事情是这样的 ...
- 基于UML的时空建模
一.基本信息 标题:基于UML的时空建模 时间:2018 出版源:东北大学学报(自然科学版) 领域分类:UML模型:RCC-8空间拓扑:Allen-13时态拓扑:时空数据:建模 二.研究背景 问题定义 ...
- 用不到 50 行的 Python 代码构建最小的区块链
引用 译者注:随着比特币的不断发展,它的底层技术区块链也逐步走进公众视野,引起大众注意.本文用不到50行的Python代码构建最小的数据区块链,简单介绍了区块链去中心化的结构与其实现原理. 尽管一些人 ...
- Debian 8下手工安装 Eclipse CDT neon.2
从 http://www.eclipse.org/downloads/packages/eclipse-ide-cc-developers/neon2 下载 eclipse-cpp-neon-2-li ...
- 大众点评selfxss结合两个csrf变废为宝(已修复,故公开,不涉及真实参数)
大众点评selfxss结合两个csrf变废为宝 漏洞不值钱,但还是蛮好玩的 漏洞信息 类型:存储型xss 场景:收藏商户后,去已收藏的商户列表可以给指定商户添加tag(与下文html标签区别) 漏洞限 ...