其他分享
首页 > 其他分享> > 上传文件出现 413 Request Entity Too Large

上传文件出现 413 Request Entity Too Large

作者:互联网

可以选择在http{ }中设置:client_max_body_size 200m;
可以选择在server{ }中设置:client_max_body_size 200m;
还可以选择在location{ }中设置:client_max_body_size 200m;
三者有区别设置到http{}内,
控制全局nginx所有请求报文大小设置到server{}内,
控制该server的所有请求报文大小设置到location{}内,控制满足该路由规则的请求报文大小
然后重启nginx
/etc/init.d/nginx restart

server {
    listen       8083;
    server_name  localhost;

    #charset koi8-r;
    #access_log  /var/log/nginx/host.access.log  main;

    location / {
        root   /workspace/dist;
        index  index.html index.htm;
		try_files $uri $uri/ /index.html;
    }

    location /api/ {
       add_header 'Access-Control-Allow-Origin' '*';
       add_header 'Access-Control-Allow-Methods' 'POST,GET,OPTIONS';
       add_header 'Access-Control-Allow-Headers' 'Authorization';
       proxy_pass http://127.0.0.1:8093/api/;
    }

    location /ws/ {
       proxy_set_header X-Real_IP $remote_addr;
       proxy_set_header Host $host;
       proxy_set_header X_Forward_For $proxy_add_x_forwarded_for;
       proxy_http_version 1.1;
       proxy_set_header Upgrade $http_upgrade;
       proxy_set_header Connection 'upgrade';
       proxy_pass http://127.0.0.1:8091/;
    } 

    location /images/ {
	root /workspace/static/platform;
        autoindex on;
        autoindex_exact_size off;
        autoindex_localtime on;
    }

    location /excel/ {
	root /workspace/static/platform;
        autoindex on;
        autoindex_exact_size off;
        autoindex_localtime on;
    }


    location /engine/ {
	root /workspace/static;
        autoindex on;
        autoindex_exact_size off;
        autoindex_localtime on;
    }

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }
    client_max_body_size 20m;

}

标签:http,autoindex,Request,Entity,Large,header,proxy,size,location
来源: https://blog.csdn.net/weixin_45124380/article/details/121404719