server { # Listen to yourdomain.com server_name yourdomain.com; # Listen to multiple domains server_name yourdomain.com www.yourdomain.com; # Listen to all domains server_name*.yourdomain.com; # Listen to all top-level domains server_nameyourdomain.*; # Listen to unspecified Hostnames (Listens to IP address itself) server_name""; }
server { listen80; server_name www.yourdomain.com; return301 http://yourdomain.com$request_uri; } server { listen80; server_name www.yourdomain.com; location /redirect-url { return301 http://otherdomain.com; } }
反向代理
1 2 3 4 5 6 7 8
server { listen80; server_name yourdomain.com; location / { proxy_pass http://0.0.0.0:3000; # where 0.0.0.0:3000 is your application server (Ex: node.js) bound on 0.0.0.0 listening on port 3000 } }