Request Header Or Cookie Too Large
1、问题
Nginx反向代理报错400 Request Header Or Cookie Too Large
400 Request Header Or Cookie Too Large
2、原因
假设需要重定向到:www.baidu.com
报错的配置如下:
location /my-pc{
access_log /etc/nginx/logs/https_my_pc.log;
proxy_pass https://www.baidu.com/my-pc;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location /my-web{
access_log /etc/nginx/logs/https_my_web.log;
proxy_pass https://www.baidu.com/my-web;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
需调整:
proxy_set_header Host $host;
3、解决
调整为:
proxy_set_header Host www.baidu.com;
全部配置如下:
location /my-pc{
access_log /etc/nginx/logs/https_my_pc.log;
proxy_pass https://www.baidu.com/my-pc;
proxy_set_header Host www.baidu.com;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location /my-web{
access_log /etc/nginx/logs/https_my_web.log;
proxy_pass https://www.baidu.com/my-web;
proxy_set_header Host www.baidu.com;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
问题解决。
OK,就这些吧。
有什么不对的还望指正,书写不易,觉得有帮助就点个赞吧!☺☺☺