Setting-up sub-domain with Nginx

March 17, 2015 1.1k views
Nginx DNS Debian

How can I set up sub-domains in Nginx?

Things I have set-up already"

  • Nginx running a Ruby rack app

  • DNS set-up with DigitalOcean

How do I create a sub-domain to root to another ruby app?

2 Answers

To do this you would:

1.) Create an A record on your existing domain in the DNS system for your new subdomain and point it to your droplet's IP.

2.) Create a second (non-default) server {} block in your nginx configuration pointing to your second app.

3.) Restart nginx with the command:

service nginx restart
Have another answer? Share your knowledge.