Skip to content

Instantly share code, notes, and snippets.

@101t
Last active December 9, 2022 07:24
Show Gist options
  • Save 101t/9f11375860a7cc8ff923c23602c43873 to your computer and use it in GitHub Desktop.
Save 101t/9f11375860a7cc8ff923c23602c43873 to your computer and use it in GitHub Desktop.
NGiNX my beloved server

NGINX frequently used configurations

NGINX Static IP Proxy Forwarding

upstream git_server {
    server xx.xx.xx.xx:6060;
}
server {
    listen 80;
    server_name git.domainname.com;

    location / {
        client_max_body_size 0;
        proxy_buffering off;
        proxy_http_version 1.1;
        proxy_pass http://git_server;
        proxy_pass_header Authorization;
        proxy_read_timeout 10000s;
        proxy_redirect off;
        proxy_set_header Connection "";
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Real-IP $remote_addr;
    }
}

Increase NGINX upload size

By default, Nginx has a limit of 1MB on file uploads. To set file upload size, you can use the client_max_body_size directive, which is part of Nginx’s ngx_http_core_module module. This directive can be set in the http, server or location context.

It sets the maximum allowed size of the client request body, specified in the "Content-Length" request header field. Here’s an example of increasing the limit to 100MB in /etc/nginx/nginx.conf file.

http {
    ...
    client_max_body_size 100M;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment