[我正在尝试上传文件,当api直接调用时它可以正常工作,但是当它位于代理之后时,它就不行了,我正在使用nginx作为反向代理]
NGINX -vnginx版本: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并且仍然相同
任何帮助将不胜感激
实际上,由于互联网连接速度慢,我找到了答案,我只是增加了超时,问题已解决!