brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: nginx client_max_body_size is 1m by default, so scope the raise to one location

Nginx
~/tips/tip-nginx-client-max-body-size-scope

location /upload/ {

Raises the 1 MB upload limit for one path and keeps it low everywhere else.

Uploads over one megabyte get a 413 before the application ever sees them.

location /upload/ {
    client_max_body_size 200m;
}

The directive works in http, server and location context, so the higher limit can sit on the upload path only and everything else keeps the small default. nginx compares the limit with the Content-Length header and answers 413 Request Entity Too Large immediately. The value 0 turns the check off, which I would avoid on a public site. PHP, Node or the backend can have its own limit, such as upload_max_filesize in PHP. Reload nginx after the change and retry the upload with a file just over the old limit.

Further reading: ngx_http_core_module: client_max_body_size

Going deeper: 🛜 Guide: AdGuard Home + Tailscale (Secure Split-Horizon DNS)

More Nginx tips sudo certbot --nginx -d example.com -d www.example.com /data/nginx/custom/server_redirect.conf map $http_upgrade $connection_upgrade { proxy_intercept_errors on; proxy_redirect http://localhost:3000/ /app/; All Nginx tips (50) All topics

Link