解决 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 ...
随机推荐
- 使用Python完成排序(快排法、归并法)
class Sort(object): def quick_sort(self, ls): self.quick_sort_helper(ls, 0, len(ls) - 1) return ls d ...
- ORB-SLAM2阅读笔记(一)从mono_eourc.cpp出发理解ORB-SLAM2
泡泡机器人上已经有公开课ORB-SLAM2的代码详解了,我也先看了一个多小时的视频,后来发现看完还是迷迷糊糊,自己没看源码,根本不明白讲的什么,因此,打开文件开始阅读源码. 为了阅读逻辑清楚,我从OR ...
- Python从入门到精通之Fifth!
字典 类名:dict 字典是无序的. 字典的创建 info = {"k1":{1:"abc",[1,2,3]},"k2":True} ...
- 利用canvas实现刮刮乐效果
最近做了个情人节表白的项目,表白内容时被遮盖的,刮开后才能显示,并且刮开一定比例后清空所有遮罩. function guaguale(obj,w,h){//obj时canvas元素 var canva ...
- Numpy1
列表转n维数组ndarray import numpy as np list=[1,2,3,4] n=np.array(list) random模块生成ndarray n1=np.random.ran ...
- pip3 install的时候报错timed out
问题: 执行pip install requests报错 Read timed out. 解决方法: 修改超时时间: pip --default-timeout=1000 install -U r ...
- Yaf 完全精通
bugs 这样 _Bootstrap 的话,会导致严重的后果,cpu 100%
- BZOJ3105-新Nim游戏
Description 传统的Nim游戏是这样的:有一些火柴堆,每堆都有若干根火柴(不同堆的火柴数量可以不同).两个游戏者轮流操作,每次可以选一个火柴堆拿走若干根火柴.可以只拿一根,也可以拿走整堆火柴 ...
- 【原创】岁月如歌 一款网易歌单生成pdf的软件
介绍 这是一款可以将网易云音乐的歌单中所有歌词输出为pdf的软件. 项目持续维护地址 http://brightguo.com/song-list-to-pdf/ 目前没有搜到相关网易歌单导出为pdf ...
- sklearn导入模块问题:python ImportError: No module named datasets
提示无法导入module 问题原因:将文件命名为sklearn.py. 解决方式:将文件命名为其他. 引用: [1] https://stackoverflow.com/questions/49635 ...