Skip to content

Instantly share code, notes, and snippets.

@pandeybk
Created June 7, 2016 23:49
Show Gist options
  • Save pandeybk/304b80ad0955cb4550d4be0baa95c80d to your computer and use it in GitHub Desktop.
Save pandeybk/304b80ad0955cb4550d4be0baa95c80d to your computer and use it in GitHub Desktop.
nginx redirect multiple domains
server {
listen 80;
server_name dgmates.com dgmates.com.sg www.dgmates.com.sg dgmates.sg www.dgmates.sg;
return 301 http://www.dgmates.com$request_uri;
}
server {
server_name www.dgmates.com;
access_log /var/log/nginx/dgmates.access.log;
location / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# Fix the “It appears that your reverse proxy set up is broken" error.
proxy_pass http://localhost:8080;
proxy_read_timeout 90;
proxy_redirect http://localhost:8080 http://www.dgmates.com;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment