Ubuntu – How to make subdomains point to different local IP addresses

dnsdomain-server

I have a domain name mydomain.com which points to a static IP address. I have configured in my modem so that all request to port 80 of this static IP will come to my local computer 192.168.1.100 (web server).

Now I want to have 2 sub-domain point to 2 another local IP:
sub1.mydomain.com —> 192.168.1.101 (host another web server)
sub2.mydomain.com —> 192.168.1.102 (host redmine server)

Is this possible? If yes, please show me how?

I use Ubuntu Server 12.

Best Answer

Answer thanks to JoshP in Server Fault:

I just recently did this. See my question. It was kind of a long back and forth, but I did get it set up in the end.

  • Set up DNS. The A record will point to your public IP. So, yourdomain.com points to your.pub.ip.add. Add CNAME records for the subdomains. So, sub1.yourdomain.com points to @, and sub2.yourdomain.com points to @, etc. Although the subdomains are all pointing to the same address, the browser will confer to the webserver which subdomain you are trying to reach.

  • Set up Apache. You'll want to set up Virtual Hosts for each subdomain (and maybe for primary domain as well). You can define the Virtual Hosts in different places... mine is defined in /etc/apache2/sites-available, and includes the <Location> directive, which is where you'll set up your reverse proxy.

This answer was given to OP in ServerFault.

Related Question