I am trying to upload file, when the api called directly it works fine, but when it is behind proxy it does not, I'm using nginx as a reverse proxy
NGINX -v nginx version: nginx/1.15.0
also 1.17 tested and the same OS: CentOS 7.0
Even though I'm setting client_max_body_size 30M in http block the ajax request gets cancelled on chrome network monitor!
Forntend: React, axios is used
Backend: nodejs 10
I tried to put the max size in http, server or location and the same without anyresponse.
Am I missing something here?
http settings:
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;
}
}
Also removed client_body_in_file_only & client_body_buffer_size and still the same
Any help would be appreciated
Actually I found the answer because of slow internet connection I just increased the timeout and the problem is fixed!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.