Nginx上传文件大小限制调整方法
新部署的服务器采用Nginx进行代理处理,近期遇到客户端上传大于1M的文件无法正常提交的问题,因此需要对Nginx的相关配置进行调整。
进入/export/servers/nginx/conf/nginx.conf配置文件,在server模块内部进行修改。
location / {
root html;
index index.html index.htm;
client_max_body_size 1000m;
}
尝试在配置中增加client_max_body_size参数,但多次重启后仍未生效。随后检查总配置文件,发现其中引用了分配置文件:
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
include domains/*; #########################分配置文件路径在此
#include domains/chat.local;
#include domains/chat.erp.com;
#include domains/support.chat.com;
#include douains/chat.com;
server {
listen 80;
server_name localhost; include domains/*命令指定了分配置文件的路径。找到了分配置文件后,在分配置文件里面进行修改。分配置文件配置如下:
server
{
listen 80;
server_name chat.erp.360buy.com;
#access_log /export/servers/nginx/logs/chat.erp.360buy.com;
location / {
proxy_pass http://tomcat;
client_max_body_size 1000m;
}
}
执行/export/servers/nginx/sbin/nginx -s reload命令重新加载配置,此时上传文件的大小限制问题得到解决。
以上内容即为本次操作的全部步骤,希望能对各位的学习有所帮助,同时也欢迎大家继续支持本站。