Setting-up sub-domain with Nginx

March 17, 2015 2.8k views
Nginx Debian DNS

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.

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