Nginx Configuration Cheatsheet

Simon Huang

Simon Huang

@simon

To log some useful Nginx Server Configurations.

Rewrite

Between Websites

server {
    listen 80;
    server_name old.com www.old.com;
    return 301 $scheme://www.new.com$request_uri;
}

301 = permanent; 302 = temporary $scheme is used to define the protocol (HTTP or HTTPS) $request_uri enable redirct for the full url path.

e.g.: www.old.com/path/ -> www.new.com/path/

Fizzy

© 2025 Fizzy All Rights Reserved.