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
- 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
- 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>