Question

Multiple websites on a single VPS; one not redirecting correctly

I’ve got 3 domains hosted on one VPS. The first one has many subdomains, each running a different application. The second and third are just a single domain (with www mapped); the first is working just fine and the third is not. The first two have been set up for a while and the third I just set up this morning.

What is happening is that when I go to the third domain in a browser, it is redirecting to cloud. on the first domain. I’ve followed the appropriate tutorials, checked my configs a thousand time (it feels like) but can’t figure out what I’m missing. I’ll post my Nginx configs (with ssl stuff removed), Ghost configs and networking below for reference.

Domain one (with the subdomains):

  • TLD & www - Ghost blog
  • cloud. - ownCloud
  • thinkup. - ThinkUp
  • fever. - Feed a Fever
  • etc, etc, etc…

Networking

$ORIGIN highgravityconsulting.com.
$TTL 1800
highgravityconsulting.com. IN SOA ns1.digitalocean.com. hostmaster.highgravityconsulting.com. 1471794828 10800 3600 604800 1800
highgravityconsulting.com. 1800 IN A 104.236.204.212
highgravityconsulting.com. 1800 IN NS ns1.digitalocean.com.
highgravityconsulting.com. 1800 IN NS ns2.digitalocean.com.
highgravityconsulting.com. 1800 IN NS ns3.digitalocean.com.
www.highgravityconsulting.com. 1800 IN CNAME highgravityconsulting.com.
fever.highgravityconsulting.com. 1800 IN A 104.236.204.212
thinkup.highgravityconsulting.com. 1800 IN A 104.236.204.212
sqlbuddy.highgravityconsulting.com. 1800 IN A 104.236.204.212
*.fever.highgravityconsulting.com. 1800 IN CNAME fever.highgravityconsulting.com.
*.thinkup.highgravityconsulting.com. 1800 IN CNAME thinkup.highgravityconsulting.com.
*.sqlbuddy.highgravityconsulting.com. 1800 IN CNAME sqlbuddy.highgravityconsulting.com.
k1._domainkey.highgravityconsulting.com.highgravityconsulting.com. 1800 IN TXT k=rsa; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC1ZgVuIc77jsZc15xCBpHVfilV7s5PNpLsY+jnx9Jgogn3kZg5ocCtaN0K10nHaWdb+wn7Y/exm0Gy9A8FtE2Lx5YbvaHSchfYCAC8sBk6EC0jsOZskHoi+16mQ1sKpLoD3gI5GcMUWzVBSO9+QKHlHUnE+0c5QNGZAidfAiLLywIDAQAB
email.highgravityconsulting.com. 1800 IN CNAME mailgun.org.
highgravityconsulting.com. 1800 IN TXT "v=spf1 include:mailgun.org ~all"
k1._domainkey.highgravityconsulting.com. 1800 IN TXT "k=rsa; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC1ZgVuIc77jsZc15xCBpHVfilV7s5PNpLsY+jnx9Jgogn3kZg5ocCtaN0K10nHaWdb+wn7Y/exm0Gy9A8FtE2Lx5YbvaHSchfYCAC8sBk6EC0jsOZskHoi+16mQ1sKpLoD3gI5GcMUWzVBSO9+QKHlHUnE+0c5QNGZAidfAiLLywIDAQAB"
piwik.highgravityconsulting.com. 1800 IN A 104.236.204.212
*.piwik.highgravityconsulting.com. 1800 IN CNAME piwik.highgravityconsulting.com.
zb13984781.highgravityconsulting.com. 1800 IN CNAME zmverify.zoho.com.
highgravityconsulting.com. 1800 IN MX 10 mx.zohomail.com.
highgravityconsulting.com. 1800 IN MX 20 mx2.zohomail.com.
k2._domainkey.highgravityconsulting.com.highgravityconsulting.com. 1800 IN TXT "k=rsa; t=y; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQClYKQQz4bBGK2qnMNWLXf50ed8GOH1ISxTL3V+qZr8Z/VWsY6U50bL1kpzbW/cgTJdS0sBTaYjffwZ7QEhjh8M4A43xhgRLn9oj/REP8l6imatymcUoTuQaOkyzAZOgOQo11dflw1L/6mYgVctC28oKtyBVnzf1gBuoTgoq/Kk6wIDAQAB"
k2._domainkey.highgravityconsulting.com.highgravityconsulting.com. 1800 IN TXT "k=rsa; t=y; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQClYKQQz4bBGK2qnMNWLXf50ed8GOH1ISxTL3V+qZr8Z/VWsY6U50bL1kpzbW/cgTJdS0sBTaYjffwZ7QEhjh8M4A43xhgRLn9oj/REP8l6imatymcUoTuQaOkyzAZOgOQo11dflw1L/6mYgVctC28oKtyBVnzf1gBuoTgoq/Kk6wIDAQAB"
f588019aea01606f7e95528582a8cfe1.highgravityconsulting.com. 1800 IN CNAME verify.bing.com.
cloud.highgravityconsulting.com. 1800 IN A 104.236.204.212
highgravityconsulting.com. 1800 IN AAAA 2604:a880:800:10::de:4001
cloud.highgravityconsulting.com. 1800 IN AAAA 2604:a880:800:10::de:4001
piwik.highgravityconsulting.com. 1800 IN AAAA 2604:a880:800:10::de:4001
sqlbuddy.highgravityconsulting.com. 1800 IN AAAA 2604:a880:800:10::de:4001
thinkup.highgravityconsulting.com. 1800 IN AAAA 2604:a880:800:10::de:4001
fever.highgravityconsulting.com. 1800 IN AAAA 2604:a880:800:10::de:4001
highgravityconsulting.com. 1800 IN TXT google-site-verification=gJ4Ci-h0-8hho8e5EELFy2aDqdJhByjv_V-Mo0f4UIM
*.cloud.highgravityconsulting.com. 1800 IN CNAME cloud.highgravityconsulting.com.

Ghost Nginx

server {
        listen 80;
        listen [::]:80;
        return 301 https://$host$request_uri;
}

server {
    listen 443 ssl spdy default deferred;
    listen [::]:443 ssl spdy default deferred;
    server_name highgravityconsulting.com www.highgravityconsulting.com;
    access_log /var/log/nginx/hgc.log;

    location / {
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header HOST $http_host;
        proxy_set_header X-NginX-Proxy true;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_pass http://127.0.0.1:2368;
        proxy_redirect off;
    }

    location ~ ^/(sitemap.xml) {
        root /var/www/ghost;
    }
}

Cloud Nginx

upstream php-handler {
  #server 127.0.0.1:9000;
  server unix:/var/run/php5-fpm.sock;
  }

server {
  listen 80;
  listen [::]:80;
  server_name cloud.highgravityconsulting.com www.cloud.highgravityconsulting.com;
  # enforce https
        add_header X-Frame-Options SAMEORIGIN;
        add_header X-Content-Type-Options nosniff;
        add_header X-XSS-Protection "1; mode=block";
  return 301 https://$server_name$request_uri;
  }

server {
  listen 443 ssl;
  listen [::]:443 ssl;
  server_name cloud.highgravityconsulting.com;

Ghost config (the important bits)

config = {
    // ### Production
    // When running Ghost in the wild, use the production environment.
    // Configure your URL and mail settings here
    production: {
        url: 'https://highgravityconsulting.com',
        mail: {
        transport: 'SMTP',
                options: {
                        service: 'Mailgun',
                        auth: {
                        user: 'postmaster@highgravityconsulting.com',
                        pass: 'XXXXXXXX'
        }
    }
},
        database: {
            client: 'sqlite3',
            connection: {
                filename: path.join(__dirname, '/content/data/ghost.db')
            },
            debug: false
        },

        server: {
            host: '127.0.0.1',
            port: '2368'
        }
    },

Domain two is just a php message board and some static html.

Domain three is another Ghost blog.

Networking

$ORIGIN tedhardy.com.
$TTL 1800
tedhardy.com. IN SOA ns1.digitalocean.com. hostmaster.tedhardy.com. 1471794855 10800 3600 604800 1800
tedhardy.com. 1800 IN NS ns1.digitalocean.com.
tedhardy.com. 1800 IN NS ns2.digitalocean.com.
tedhardy.com. 1800 IN NS ns3.digitalocean.com.
tedhardy.com. 1800 IN A 104.236.204.212
tedhardy.com. 1800 IN AAAA 2604:a880:800:10::de:4001
www.tedhardy.com. 1800 IN CNAME tedhardy.com.
*.tedhardy.com. 1800 IN CNAME www.tedhardy.com.

Nginx

server {
        listen 80;
        listen [::]:80;
        return 301 https://$host$request_uri;
}

server {
    listen 443 ssl spdy default deferred;
    listen [::]:443 ssl spdy default deferred;
    server_name tedhardy.com www.tedhardy.com;

    location / {
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header HOST $http_host;
        proxy_set_header X-NginX-Proxy true;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_pass http://127.0.0.1:2369;
        proxy_redirect off;
    }

    location ~ ^/(sitemap.xml) {
        root /var/www/tedhardy;
    }
}

Ghost config

config = {
    // ### Production
    // When running Ghost in the wild, use the production environment.
    // Configure your URL and mail settings here
    production: {
        url: 'https://www.tedhardy.com',
        mail: {
        transport: 'SMTP',
                options: {
                        service: 'Mailgun',
                        auth: {
                        user: 'postmaster@highgravityconsulting.com',
                        pass: 'XXXXXXX'
        }
    }
},
        database: {
            client: 'sqlite3',
            connection: {
                filename: path.join(__dirname, '/content/data/ghost.db')
            },
            debug: false
        },

        server: {
            host: '127.0.0.1',
            port: '2369'
        }
    },

Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Accepted Answer

So, I am quite annoyed right now. I had this thought while I was working the problem that it was a cached DNS entry on my laptop. I cleared cache, rebooted, etc, problem still was there. What I didn’t do is try it from a different device. Anyone want to guess what happened when I visited from my phone? Yeah, it was working the whole time. Regardless, I had to put everything back to the old server for that third domain for the moment anyway due to needing to post something for people to read. Such is life; live and learn.

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel