Home > Backend Development > PHP Tutorial > How to modify the size of uploaded files in nginx

How to modify the size of uploaded files in nginx

小云云
Release: 2023-03-22 15:34:02
Original
2548 people have browsed it

This article mainly shares with you how nginx can modify the size of uploaded files, build your own server, and use nginx as a proxy. Client files larger than 1M cannot be uploaded normally, and nginx directly reports an error. The uploaded file is too large, so I modified the nginx configuration and it worked.

Add the client_max_body_size field according to what is said on the Internet, no matter how you restart nginx, it will not work. Later I found out there was something wrong with the placement!

server {
        listen       80;
        server_name  localhost;
        client_max_body_size 10M;

        location /web {            alias   D:/web;
            index main.html;            
        }
        location /web/service {
            proxy_pass   http://192.168.1.188:8080/service;     
        }
        location /web/service/upload {
            proxy_pass   http://192.168.1.188/upload;
        }       
    }
Copy after login
Copy after login

client_max_body_size 10M It must be placed under the server_name under the server, not in the curly brackets of localhost/web

Self-built server, use nginx acting. Client files larger than 1M cannot be uploaded normally, and nginx directly reports an error that the uploaded file is too large, so I modified the nginx configuration and it worked.
Add the client_max_body_size field according to what is said on the Internet. No matter how you restart nginx, it will not work. Later I found out there was something wrong with the placement!

server {
        listen       80;
        server_name  localhost;
        client_max_body_size 10M;

        location /web {            alias   D:/web;
            index main.html;            
        }
        location /web/service {
            proxy_pass   http://192.168.1.188:8080/service;     
        }
        location /web/service/upload {
            proxy_pass   http://192.168.1.188/upload;
        }       
    }
Copy after login
Copy after login

client_max_body_size 10M must be placed under the server_name under the server, not within the curly brackets of localhost/web.

Related recommendations:

Change PHP upload size limit

How to solve the file upload size limit of PHP and Nginx

How to set image file upload size in PHP_PHP tutorial

The above is the detailed content of How to modify the size of uploaded files in nginx. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template