Subdomains pointing to same droplet in different ports?

January 5, 2014 10.2k views
Hi, we would like to have 3 subdomains resolving to the same IP (same droplet) but pointing to 3 different servers that will be running on it. The servers were developed in GO programming language (golang). One domain will be the API serving on port X: Other one will be our Admin Dashboard on port Y: And the last one will be our website running probably on port Z: How can we config the DNS to accomplish our desired setup? Can you help us with that? Thank you very much in advance.
1 Answer
Firstly, create a DNS record for each of the subdomains. The DNS records tell the browser which server/IP address it should connect to. Browsers assume port 80 by default.

In order to map each subdomain to a different port, you will need to use a reverse proxy such as nginx.

You will need to insert this into each virtualhost instead of the virtualhost config in the said article.
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.
  • Hi kamaln7

    I need same setup. Unfortunately your second link does not work (any more). Could you please explain again what would be the difference to direct to a subdomain?

    Thanks, Alex

Have another answer? Share your knowledge.