如何解决Nginx 代理负载均衡不允许 POST 大于 1MB
关于 nginx 的这个话题已经讨论了一千次了,但是我尝试了我在互联网上发布的所有内容,但它对我不起作用。
如果我直接通过服务器收费而不通过 nginx 代理负载均衡器,一切都会完美加载。 它不会发送大于 1mb 的帖子,我尝试以 POST 格式上传 2mb pdf 以将其传递给 mysql,但它给了我一个错误。如果 pdf 小于 1mb,则 POST 工作正常。
谢谢
server {
# listen 443 ssl;
listen 443;
server_name test.com;
ssl on;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
ssl_certificate /etc/letsencrypt/live/appnet.dev/cert.pem;
ssl_certificate_key /etc/letsencrypt/live/appnet.dev/privkey.pem;
ssl_trusted_certificate /etc/letsencrypt/live/appnet.dev/fullchain.pem;
client_max_body_size 800M;
# server_names_hash_bucket_size 64;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 300;
proxy_max_temp_file_size 16384m;
gzip on;
gzip_vary on;
gzip_min_length 10240;
gzip_proxied expired no-cache no-store private auth;
gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml;
gzip_disable "MSIE [1-6]\.";
gzip_comp_level 6;
gzip_proxied any;
if ($http_host ~* '^test.com'){
rewrite ^(.*)$ https://www.test.com$request_uri redirect;
}
#return 301 https://www.test.com$request_uri;
location / {
set_real_ip_from 173.245.48.0/20;
set_real_ip_from 103.21.244.0/22;
set_real_ip_from 103.22.200.0/22;
set_real_ip_from 103.31.4.0/22;
set_real_ip_from 141.101.64.0/18;
set_real_ip_from 108.162.192.0/18;
set_real_ip_from 190.93.240.0/20;
set_real_ip_from 188.114.96.0/20;
set_real_ip_from 197.234.240.0/22;
set_real_ip_from 198.41.128.0/17;
set_real_ip_from 162.158.0.0/15;
set_real_ip_from 104.16.0.0/12;
set_real_ip_from 172.64.0.0/13;
set_real_ip_from 131.0.72.0/22;
real_ip_header X-Forwarded-For;
# real_ip_header CF-Connecting-IP;
real_ip_recursive on;
proxy_pass https://backend;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
#proxy_set_header X-Forwarded-For $http_x_forwarded_for;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# proxy_set_header X-Forwarded-Proto $proxy_x_forwarded_proto;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
server {
listen 80;
# listen 80 ssl;
ssl on;
server_name test.com;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
ssl_certificate /etc/letsencrypt/live/appnet.dev/cert.pem;
ssl_certificate_key /etc/letsencrypt/live/appnet.dev/privkey.pem;
ssl_trusted_certificate /etc/letsencrypt/live/appnet.dev/fullchain.pem;
gzip on;
gzip_types text/plain application/xml;
gzip_proxied no-cache no-store private expired auth;
gzip_min_length 1000;
client_max_body_size 800M;
# client_max_body_size 0;
location / {
proxy_pass https://backend;
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 X-Forwarded-Proto $scheme;
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。