I had a client who had their local server setup under domain.com instead of properly under local.domain.com or something similar. It caused a bit of a headache (you could view their new site from outside their local office, but in their local office the old website was still showing.)
Their local server guy (thanks Will) helped me solve the issue. Their website needed to use only www.
Here’s his notes:
Company XYZ Mortuary has two separate DNS systems1. The public-facing DNS server that you control
2. The internal DNS server for Company XYZ’s private network that we control
Since both of these servers are authoritative for the CompanyXYZ.com domain, both need to be updated when IP addresses of public servers change.
The other issue we had was the web site removing the www from the URL, which caused computers on Company XYZ’ private network to access an internal server. Windows domain controllers reserve the IP address for the domain name for themselves, and modifying this behavior breaks functionality such as DFS and Exchange. For this reason, Microsoft and other OS vendors recommend using a TLD that will never be used on the Internet, such as .local.
And here is the adjusted nginx config file to use www & point appropriately.
The key line(s) are:
server_name company-xyz.com;
rewrite ^/(.*) http://www.company-xyz.com/$1 permanent;
1 upstream domain4 { 2 server 127.0.0.1:3400; 3 } 4 5 server { 6 listen 80; 7 server_name company-xyz.com; 8 rewrite ^/(.*) http://www.company-xyz.com/$1 permanent; 9 } 10 11 12 server { 13 listen 80; 14 server_name www.company-xyz.com; 15 16 access_log /home/username/public_html/railsapp/shared/log/access.log; 17 error_log /home/username/public_html/railsapp/shared/log/error.log; 18 19 root /home/username/public_html/railsapp/current/public/; 20 index index.html; 21 22 location / { 23 proxy_set_header X-Real-IP $remote_addr; 24 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 25 proxy_set_header Host $http_host; 26 proxy_redirect false; 27 28 if (-f $request_filename/index.html) { 29 rewrite (.*) $1/index.html break; 30 } 31 32 if (-f $request_filename.html) { 33 rewrite (.*) $1.html break; 34 } 35 36 if (!-f $request_filename) { 37 proxy_pass http://domain4; 38 break; 39 } 40 } 41 42 } 43 44 45 server { 46 47 listen 443; 48 ssl on; 49 ssl_certificate /etc/ssl/certs/company-xyz.com.crt; 50 ssl_certificate_key /etc/ssl/private/companyxyz.key; 51 52 server_name company-xyz.com; 53 rewrite ^/(.*) http://www.company-xyz.com/$1 permanent; 54 55 56 } 57 58 59 server { 60 61 listen 443; 62 ssl on; 63 ssl_certificate /etc/ssl/certs/company-xyz.com.crt; 64 ssl_certificate_key /etc/ssl/private/companyxyz.key; 65 66 server_name www.company-xyz.com; 67 68 access_log /home/username/public_html/railsapp/shared/log/access.log; 69 error_log /home/username/public_html/railsapp/shared/log/error.log; 70 71 root /home/username/public_html/railsapp/current/public/; 72 index index.html; 73 74 location / { 75 proxy_set_header X_FORWARDED_PROTO https; 76 77 proxy_set_header X-Real-IP $remote_addr; 78 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 79 proxy_set_header Host $http_host; 80 proxy_redirect false; 81 82 if (-f $request_filename/index.html) { 83 rewrite (.*) $1/index.html break; 84 } 85 86 if (-f $request_filename.html) { 87 rewrite (.*) $1.html break; 88 } 89 90 if (!-f $request_filename) { 91 proxy_pass http://domain4; 92 break; 93 } 94 } 95 96 }
Spitfire Sky | github | archives | resume