POST数据太大,导致nodejs服务请求失败,本地好好的,但是在服务器上修改之后仍然不成功
仔细想了下,服务器使用了nginx反向代理,nginx限制了请求大小,默认是1M,超出限制会出现413错误
解决的方法
server { listen 3001; server_name 127.0.0.1; proxy_cache nginx; proxy_cache_valid 301 302 20m; proxy_cache_valid any 5m; location / { proxy_pass http://127.0.0.1:2001; client_max_body_size 1000m; gzip on; gzip_min_length 1k; gzip_buffers 4 16k; #gzip_http_version 1.0; gzip_comp_level 2; gzip_types text/plain application/json application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png; gzip_vary off; gzip_disable "MSIE [1-6]."; #缓存设置 proxy_ignore_headers Set-Cookie Cache-Control; proxy_hide_header Cache-Control; proxy_hide_header Set-Cookie; proxy_set_header Host $proxy_host:$proxy_port; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; add_header X-Via $server_addr; add_header X-Upstream $upstream_addr; add_header Nginx-Cache $upstream_cache_status; } }
重启nginx