nginx - 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;
}
}
解决方案
推荐阅读
- javascript - Fabric JS在缩放视图中获取鼠标点击的相对坐标
- flutter - 如何在颤动中制作这样的自定义应用栏?
- javascript - 为什么获取信息表单字段不起作用
- fortran - 假定字符长度为 (1) 的实体必须是虚拟参数或 PARAMETER
- python - 如何将碰撞添加到 tkinter 中的对象(圆圈)列表中?
- python - RuntimeError:为 EfficientDet 加载 state_dict 时出错
- java - 为什么我会收到 IndexOutOfBoundsException 错误?
- c++ - 将参数值从构造函数传递给接受引用的函数
- excel - 为什么我生成随机数的种子不起作用?
- ckeditor - 有没有一种简单的方法可以向 CKEv5 工具栏添加新的样式功能按钮?