tgoolsby
By:
tgoolsby

Nginx server block works for one subdomain but not the other.

December 25, 2015 1.6k views
Nginx Ghost Ubuntu

I am trying to install two instances of Ghost at two different subdomains: one.example.com, two.example.com. I followed this guide to setup multiple Ghost instances: https://www.digitalocean.com/community/tutorials/how-to-serve-multiple-ghost-blogs-on-one-vps-using-nginx-server-blocks

When I visit one.example.com, the blog loads. However, when I visit two.exmaple.com or www.example.com, I get the vanilla nginx page. Whether or not I have the server block for ghost two enabled, two.example.com goes to the nginx page.

I tried removing all server blocks from conf.d and sites-enabled. In this case, one.example.com gives me the Unable to Connect page on Firefox. the www and two subdomains still go to the nginx page.

My Zone file is:

example.com. 1800 IN A 0.0.0.0
www.example.com. 1800 IN CNAME example.com.
one.example.com. 1800 IN CNAME example.com.
two.example.com. 1800 IN CNAME example.com.

Furthermore, If the only file I have in sites-enabled is

server {
    listen 80;
    server_name two.example.com;

    location / {
        proxy_set_header HOST $http_host;
        proxy_pass http://127.0.0.1:2368;
        proxy_redirect off;
    }
}

then one.example.com will load ghost page, and two will load nginx page. In this case, the url in ghost/config.js is set to http://two.example.com and the port is set to 2368.

I'm using node v4.2.4 and nginx 1.4.6 on Ubuntu. I installed these manually following the tutorial, but I guess I missed something somewhere and I can't figure out where.

2 comments
1 Answer

Problem solved. Firefox wasn't refreshing the cache sometimes. I forced it to check for outdated cache every time the page loads.

Have another answer? Share your knowledge.