Wednesday, February 15, 2012

Reverse proxy setting for Nginx to route by domain name

1, Assuming the server will own 2 domain names: and
You should get same IP address while ping these 2 domain names.
2, By default, when you visit it will redirect to
3, If you visit domain name, you will get the response from web server serving on
   1: server
   2: {
   3:         listen 80;
   4:         server_name ~^(www\.)?(?<domain>.+)$;
   6:         location / {
   7:                 #default redirect
   8:                 proxy_pass;
  10:                 #redirect by domain name.
  11:                 if ($domain ~* mysite)
  12:                 {
  13:                         proxy_pass;
  14:                 }
  15:               proxy_set_header Host $host;
  16:                 proxy_set_header X-Real-IP $remote_addr;
  17:                 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  18:         }
  19:         access_log      /var/log/nginx/rproxy.access_log;
  20:         error_log       /var/log/nginx/rproxy.error_log;
  22: }



  1. When it comes to browsing over the internet, the first and the far most important thing that one should consider is protecting your private and personal information over the internet or make maximum efforts to save his personal data and other information from the hackers one should consider going with using a proxy address rather than his own IP address. Bonuses

  2. Why is it important for you to choose a domain name you are happy with? You need to realize that once you start your business and/or have a lot of customers you will not be able to change your domain name. Namecheap domain registration coupon