
Nginx报错400——unkown the request
报错场景
访问请求第一次 OK
,第二次 unkown the request
解决方法
- 查看反向代理的配置是否出错
server { location /api { default_type application/json; #internal; keepalive_timeout 30s; keepalive_requests 1000; #支持keep-alive proxy_http_version 1.1; rewrite /api(/.*) $1 break; proxy_pass_request_headers on; #more_clear_input_headers Accept-Encoding; proxy_next_upstream error timeout; # proxy_pass http://127.0.0.1:8081; proxy_pass http://backend; } } upstream backend { server 127.0.0.1:8081 max_fails=5 fail_timeout=10s weight=1; server 127.0.0.1:8082 max_fails=5 fail_timeout=10s weight=1; }
发现,之前做集群任务时,使用了两个端口进行代理,因此导致 一次成功,另一次失败
注释掉不用的端口
upstream backend { server 127.0.0.1:8081 max_fails=5 fail_timeout=10s weight=1; # server 127.0.0.1:8082 max_fails=5 fail_timeout=10s weight=1; }
重启服务
nginx.exe -s stop nginx.exe
问题解决
- 感谢你赐予我前进的力量
赞赏者名单
因为你们的支持让我意识到写文章的价值🙏
本文是原创文章,采用 CC BY-NC-ND 4.0 协议,完整转载请注明来自 zxb
评论
隐私政策
你无需删除空行,直接评论以获取最佳展示效果