【发布时间】:2020-03-04 15:54:01
【问题描述】:
我正在尝试上传文件,当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 并且仍然相同
任何帮助将不胜感激
【问题讨论】:
标签: node.js nginx centos axios formidable