我知道之前已经多次询问过这个问题,但我无法在配置中使用它。尝试上传大于默认nginx值client_max_body_size
且大小为1 MB的文件时,我收到413错误。
这是我的配置:
nginx.conf:
http {
client_max_body_size 500M;
limit_req_status 429;
limit_conn_status 429;
limit_req_zone $binary_remote_addr zone=worktoday:40m rate=10r/s;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
gzip on;
gzip_disable "msie6";
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
mysite.com:
server {
client_max_body_size 500M;
listen 80;
location / {
client_max_body_size 500M;
proxy_pass http://backend;
proxy_set_header Host $host;
}
}
upstream backend {
client_max_body_size 500M;
least_conn;
server 172.16.10.10;
server 172.16.10.12;
}
我尝试了所有组合,将client_max_body_size
放在所有位置(如现在),仅在某些位置,将其设置为0(禁用任何限制)等等。
我迫切希望解决这个问题。
在nginx后面有一个带有gunicorn的烧瓶应用程序。我已经尝试了自己的应用程序(前面没有nginx)并且它可以工作。
我非常感谢这里的任何帮助,谢谢。
答案 0 :(得分:2)
好的,所以昨天当我问这个问题时我已经完全烧坏了,我忘记了我们的部署配置。
我们的主服务器充当负载均衡器,我们还有其他两台服务器,它们也有nginx。我忘记了其他两个nginx的存在,那些是那些拒绝请求的人。
在这两个上设置client_max_body_size
最终解决了我的问题。
提示:有时候最好还是睡觉并重新回来解决问题。