Home > Article > Backend Development > How to modify the size of uploaded files in nginx
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; } }
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; } }
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:
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!