LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   Apache : Forward request to another server (https://www.linuxquestions.org/questions/linux-server-73/apache-forward-request-to-another-server-703665/)

tuty_richard 02-10-2009 11:57 AM

Apache : Forward request to another server
 
I have static IP set to my router. I am running two web servers. I have redirected my 80 port from the router to my server 1 its working fine. I need a help in setting up like this

I have domain say mydomain.com when ever I type mydomain.com in my browser it comes to my router then to my server 1 thats fine.

I have sub domain say sub.mydomain.com when ever I type sub.mydomain.com the router redirects to my webserver1. but what I need is my sub.mydomain has to be served by my server 2.

<VirtualHost *:80>
ServerName sub.mydomain
ServerAlias www.sub.mydomain
RewriteEngine On
RewriteRule ^(.*)$ http://192.168.0.101$1 [P]
</VirtualHost>

By adding this setup when ever I type sub.mydomain it redirects to my server 2 that is fine. But when my url changes to like sub.mydomain.com/mail the browser shows like http://192.168.0.101:80/mail. How to over come this problem please help me.

Thanks
Richard

routers 02-14-2009 08:38 AM

richard. try this way

#important to edit local ip in /etc/hosts for lan ip 192.168.0.101
# 192.168.0.101 sub.mydomain <- /etc/hosts for both server1 and server2
<VirtualHost *:80>
ServerName sub.mydomain
RewriteEngine On
RewriteRule ^(.*)$ http://sub.mydomain/$1 [P]
UseCanonicalName On
RewriteRule ^(.*)$ [L]
</VirtualHost>


give a try


All times are GMT -5. The time now is 06:28 PM.