nginx - Nginx Proxy POST fails GET is successful
问题描述
I have nginx running as a proxy in front of a .net core application. The web page is being served correctly and all GET requests work fine. However, all of the POST requests fail with a 404.
Config:
location ~ / {
proxy_pass http://127.0.0.1:5000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
client_max_body_size 15M;
more_clear_input_headers 'Accept-Encoding';
}
Error Log:
111.111.111.111 - - [25/Feb/2020:19:56:37 +0000] "GET /Content/favicon.png HTTP/2.0" 200 1003 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:73.0) Gecko/20100101 Firefox/73.0"
111.111.111.111 - - [25/Feb/2020:19:56:51 +0000] "POST /api/encode/ASCII/dGVzdA== HTTP/2.0" 400 463 "https://example.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:73.0) Gecko/20100101 Firefox/73.0"
What am I doing wrong?
解决方案
The solution was to either clear the Connection
header, or set it to keep-alive
location ~ / {
proxy_pass http://127.0.0.1:5000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'keep-alive';
client_max_body_size 15M;
more_clear_input_headers 'Accept-Encoding';
}
推荐阅读
- git - Git-LFS 添加文件类型(不加倍 repo 大小)
- python - rpy2应用函数后数据框没有变化
- r - 如何使用网状将python函数应用到r列表?
- javascript - Polymer 3 刷新组件
- c++11 - 如何正确使用 QGridLayout 在 Qt5 中将Widgets 彼此相邻添加
- reactjs - npm start 不起作用,因为他找不到 react-scripts
- caching - 如何将清漆添加到拇指,s3 设置?
- wordpress - Wordpress 在主页上询问用户名和密码
- php - 页面总是重定向一次?
- swift - 'window' 不是 Swift iOS 开发中的标识符吗?