How to point sub-domains to different local IP

My question is the same with How to point a subdomain to local server with dynamic IP. The difference is that I do have a static IP from my ISP, I think i do not need to use DynDNS right? so what can I use instead?

My goal is to point each subdomain to different web server like this:
mydomain.com --> 192.168.1.100 (main web server)
sub1.mydomain.com --> 192.168.1.101(web server 1)
sub2.mydomain.com --> 192.168.1.102(web server 2)

I have tried to use proxy module of Apache follow instruction here but not succeed. When i access to sub1.mydomain.com by browser, it always lead to mydomain.com.
Can I do this by this approach? if not please show me another way.

I use Ubuntu Server 12.04

[SOLVED]
Solution

  1. Set up DNS

The A record point to public IP:
1 @ public.ip
2 www public.ip

The CNAME record point to subdomain:
1 sub1 mydomain.com
2 sub2 mydomain.com

  1. Set up Apache.

Add sub1 and sub2 to /etc/apache2/sites-available

sub1:

<VirtualHost *:80>    
        ServerName sub1.mydomain.com    
        <Proxy *>
                Order deny,allow
                Allow from all
        </Proxy>    
        <Location />
                ProxyPass http://192.168.1.101/
                ProxyPassReverse http://192.168.1.101/
        </Location>    
</VirtualHost>

sub2:

<VirtualHost *:80>    
        ServerName sub2.mydomain.com    
        <Proxy *>
                Order deny,allow
                Allow from all
        </Proxy>    
        <Location />
                ProxyPass http://192.168.1.102/
                ProxyPassReverse http://192.168.1.102/
        </Location>    
</VirtualHost>

Solution 1:

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.

Solution 2:

This isn't really a web server issue, it should be sorted out in your DNS. You control the DNS for mydomain.com, right? So add A records for the subdomains pointing to the relevant IP addresses, ensure those addresses are served by web servers that know they should be serving those domains, and all will work.

Having all subdomain requests go through the main webserver for mydomain.com, like some kind of weird load-balancer, is inefficient and unnecessary.

Edit: sorry, I had not appreciated that you were using 192.168.0.0/16 addresses to signify that your subdomain servers were on an internal network; I had thought that you were merely redacting the addresses as you had redacted the domain names.

So: are all the webservers on the internal network? Or only the subdomain ones? If the latter, what kind of VPN connection is there currently between the main web server and the internal servers?