nginx subdomain one server help

Posted May 24, 2014 7.3k views
Hello. I'm a bit new to this. I have a droplet of ruby application. Ubuntu 12.1, nginx + unicorn. I want to create a subdomain that calls for a different directory. -> /home/rails -> /var/www/sub/public_html I've followed these two tutorial: My zone file is: @ IN A blog IN A * CNAME @ *.sub CNAME My "default" nginx file is: server { listen 80; root /home/rails/public; server_name; index index.htm index.html; location / { try_files $uri/index.html $uri.html $uri @app; } # location ~* ^.+\.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js|mp3|flv|mpeg|avi)$ { location ~* ^.+\.(jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|mp3|flv|mpeg|avi)$ { try_files $uri @app; } location @app { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_redirect off; proxy_pass http://app_server; } } and my "" file is: server { listen 80 default_server; listen [::]:80 default_server ipv6only=on; root /var/www/blog/public_html; index index.html index.htm index.php; server_name; location / { try_files $uri $uri/ =404; } } Both have symbolic links in /etc/nginx/sites-enabled However if I go to it shows content. I'm not sure what I'm missing. Thanks.

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.

Submit an Answer
9 answers
Opps I forgot to edit out the site under's nginx file, but everything is consistent in the naming. I've double and tripled checked it. Thanks.
Have you restarted nginx after adding the second server block?

Are you sure the symlinks are set up properly? Can you pastebin the output of this command?
ls -lah /etc/nginx/sites-enabled
Hello. Yes I did restart nginx.
Here is the pastebin for that command
Also here's the pastebin for uneditted nginx files
Hmm. Does /etc/nginx/sites-available/ exist? (run ls /etc/nginx/sites-available/ Try removing the default_server options, does that change anything?
The ls command returns:

if I remove the default link under sites-enabled with
sudo rm /etc/nginx/sites-enabled/default
then everything points to the blog, even

should I rename "default" file into ""?

Also I followed this
to set up rails
It says nginx listens to port 80 and forwards the request to Unicorn, I'm not sure if that has anything to do with it conflicting with a secondary file.
Ah I found the default_server you were talking about. Removing it made it work :D

Thank you very much.
Awesome! Glad to hear it's working now! :)