Stefan Hornburg (Racke)

Nginx Cheatsheet

    Redirects

    Blocks

    Checks

    Performance Measurement

Redirects

Permanently redirect from web root to specific URI:

location = / {
    rewrite ^ /sympa/ permanent;
}

Blocks

Stop the POST flood to /autodiscover/autodiscover.xml generated by MS Office/Outlook:

location ~ ^/[aA]uto[dD]iscover/autodiscover.xml$ {
        return 403;
}

Checks

nginx -t checks the configuration and nginx -T shows the complete configuration in the order nginx processes the configuration.

Performance Measurement

log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"';

log_format performance '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for" ' 'request_time=$request_time ' 'upstream_response_time=$upstream_response_time ' 'upstream_connect_time=$upstream_connect_time ' 'upstream_header_time=$upstream_header_time';