我需要配置 nginx + gunicorn 才能在两台服务器中上传大于默认最大大小的文件。
我的 nginx .conf 文件如下所示:
server {
# ...
location / {
proxy_pass_header Server;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Scheme $scheme;
proxy_connect_timeout 60;
proxy_pass http://localhost:8000/;
}
}
Run Code Online (Sandbox Code Playgroud)
这个想法是允许两个位置的 20M 请求:
/admin/path/to/upload?param=value
/installer/other/path/to/upload?param=value
我尝试添加location
与我在此处粘贴的指令相同级别的指令(获取 404 错误),并尝试将它们添加到location /
指令中(获取413 Entity Too Large
错误)。
我的位置指令以最简单的形式如下所示:
location /admin/path/to/upload/ {
client_max_body_size 20M;
}
location /installer/other/path/to/upload/ {
client_max_body_size 20M;
}
Run Code Online (Sandbox Code Playgroud)
但它们不起作用(实际上我测试了很多组合,我很绝望地想着这个。
请帮助如果可以:我需要设置哪些设置才能使其工作?
非常感谢!