簡體   English   中英

nginx client_max_body_size 工作不正常

[英]nginx client_max_body_size is not working correctly

我正在嘗試上傳文件,當直接調用 api 時它工作正常,但是當它在代理后面時它沒有,我使用 nginx 作為反向代理

NGINX -v nginx 版本:nginx/1.15.0

也經過 1.17 測試和相同的操作系統:CentOS 7.0

即使我在 http 中設置 client_max_body_size 30M 阻止 ajax 請求在 chrome 網絡監視器上被取消!

Forntend:React,使用 axios

后端:nodejs 10

我試圖將最大尺寸放在 http、服務器或位置,並且沒有任何響應。

我在這里錯過了什么嗎?

http 設置:

http {
include       /etc/nginx/mime.types;
default_type  application/octet-stream;

log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                  '$status $body_bytes_sent "$http_referer" '
                  '"$http_user_agent" "$http_x_forwarded_for"';

access_log  /var/log/nginx/access.log  main;

sendfile        on;
#tcp_nopush     on;

client_body_in_file_only clean;
client_body_buffer_size 32K;
client_max_body_size 30M;


keepalive_timeout  65;

#gzip  on;

include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*.conf;
}

server {
    listen 80;
    server_name my_server_name;
    return 301 https://my_server_name;
}
server {

listen 443 ssl default_server;
server_name my_server_name;
ssl_certificate     path_to_cert;
ssl_certificate_key path_to_key;
root  path_to_build;
index index.html index.htm;

client_body_in_file_only clean;
client_body_buffer_size 32K;
client_max_body_size 30M;

location /api/ {
    proxy_set_header   X-Forwarded-For $remote_addr;
    proxy_set_header   Host $http_host;
    proxy_pass http://127.0.0.1:3003/api/;
    proxy_pass_request_headers on;
    proxy_cache                off;

client_body_in_file_only clean;
client_body_buffer_size 32K;
client_max_body_size 30M;

}
location / {

            try_files $uri /index.html;
    }
}

還刪除了 client_body_in_file_only 和 client_body_buffer_size 並且仍然相同

任何幫助,將不勝感激

實際上,由於互聯網連接速度慢,我找到了答案,我只是增加了超時時間,問題就解決了!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM