dtoebe
By:
dtoebe

Set up a sub domain on a Nginx server Ubuntu 12.04

December 6, 2013 25.5k views
I am trying to learn as I go: I have set up Nginx server on my Ubuntu 12.04 Droplet. I have successfully pointed my domain (registered @ godaddy) to my droplet (I can see the example page I created). Now I wanted to create a sub domain on the same server. I created my config file: cp /etc/nginx/available-sites/default /etc/nginx/available-sites/mydomain.com and linked it in sites-enabled in /etc/nginx/available-sites/mydomain.com I used the default code and pointed it to mydomain.com and to the folder containing the site, and like I said that works fine. now I have tried to add to that same config file, before my main server class a new server class shown here: server { listen 80; server_name dev.mydomain.com; location / { root /home/myusrnm/sites/site-drectory; } } I know very basic but I am trying to build as I go. then in godaddy I added dev to my A record and pointed it to my droplet's IP (which is the same as mydomain.com). I have ping mydomain.com, and ping dev.mydomain.com, and everything is fine. My Nginx server restarted fine as well. It's been about an hour and I still can't point my browser to dev.mydomain.com. Do I have to set something up on the Digital Ocean DNS? or what am I missing?
5 Answers
Hello,

Please check out the following link and se if it helps you out.

https://www.digitalocean.com/community/articles/how-to-set-up-nginx-virtual-hosts-server-blocks-on-ubuntu-12-04-lts--3
by Etel Sverdlov
This tutorial shows you how to set up a new directory, how to grant the correct permissions, how to add content to a new page, how to turn on virtual hosting, and how to, if needed, set up local hosts. Virtual Hosts are used to run more than one website or domain off of a single server and IP address. When used with nginx, virtual hosts are called Server Blocks. This tutorial covers setting up server blocks on an Ubuntu server.
Thank you, I've already read that on a couple times... I think the issue I am having is more of a DNS issue
Well I did get it... I used this Tut: https://www.digitalocean.com/community/articles/how-to-set-up-and-test-dns-subdomains-with-digitalocean-s-dns-panel, and set it up in my DO DNS. Not sure if I had to set it up in godaddy.... I'll test that in my next prodject
"...I still can't point my browser to dev.mydomain.com."

What do you mean by that? Do you get any type of error message?

"... and ping dev.mydomain.com, and everything is fine."

How so? Are you getting your DigitalOcean droplet's IP address?

"Do I have to set something up on the Digital Ocean DNS?"

Not if you're using GoDaddy's nameservers.
Thank you for trying to help, but I did have to make changes in DO DNS. As seen in my answer just before yours.
Have another answer? Share your knowledge.