LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   routing requests to internal computer (https://www.linuxquestions.org/questions/linux-server-73/routing-requests-to-internal-computer-589199/)

anthill 10-03-2007 03:36 PM

routing requests to internal computer
 
Hi

Not sure if this is the right place, but i'll explain my setup:

I have two domains, domain1.com and domain2.com
I have a linux machine for all php requests (domain1.com) 192.168.1.100
I have a windows machine for all asp requests (domain2.com) 192.168.1.200

if a request is made to domain1.com it routes to 192.168.1.100, yet if i a request is made to domain2.com it routes to 192.168.1.200. Currently all port 80 requests go to 192.168.1.100, i want this box (the linux one) to route the URL domain2.com to go to 192.168.1.100.

How do i go about doing this, i've tried using apahces rewrite engine but it physically changed the IP to 192.168.1.200 which you or i cant connect to outside the internal LAN. I've tried configuring BIND but can't seem to get it to work, in fact i read somewhere that BIND doens't care about URLs so this wont work.

Does anybody know how i can achieve this?

Thanks

Ant

digitalnerds 10-03-2007 03:51 PM

Quote:

Originally Posted by anthill (Post 2912170)
Hi

Not sure if this is the right place, but i'll explain my setup:

I have two domains, domain1.com and domain2.com
I have a linux machine for all php requests (domain1.com) 192.168.1.100
I have a windows machine for all asp requests (domain2.com) 192.168.1.200

So
domain1.com == 192.168.1.100 = linux/php
domain2.com == 192.168.1.200 = windows/asp

Quote:

Originally Posted by anthill (Post 2912170)
if a request is made to domain1.com it routes to 192.168.1.100, yet if i a request is made to domain2.com it routes to 192.168.1.200. Currently all port 80 requests go to 192.168.1.100, i want this box (the linux one) to route the URL domain2.com to go to 192.168.1.100.
How do i go about doing this, i've tried using apahces rewrite engine but it physically changed the IP to 192.168.1.200 which you or i cant connect to outside the internal LAN. I've tried configuring BIND but can't seem to get it to work, in fact i read somewhere that BIND doens't care about URLs so this wont work.

Does anybody know how i can achieve this?

Thanks

Ant



Let me see if i understand ...
If a request is made do domain1.com the linux box with 192.168.1.100 serves the request. And if a request is made to domain2.com the windows box with 192.168.1.200 should serve the requests.
Well knowing that port 80 is redirected to 192.168.1.100 (linux box) you want the linux to route the requests for domain2.com to 192.168.1.100 (ITSELF?) or to 192.68.1.200 which is the windows box.
So do you have any external IP's that are actually pointing to domain1.com and domain2.com? .. If yes why dont you redirect ports so all requests made to domain1.com are mapped to 192.168.1.100:80 while all requests made to domain2.com being mapped to 192.168.1.200:80.
I dont really know all your configuration over there to give more specific hints and advices.

Regards
Andy

anthill 10-03-2007 06:11 PM

Quote:

Originally Posted by digitalnerds (Post 2912186)
Let me see if i understand ...
If a request is made do domain1.com the linux box with 192.168.1.100 serves the request. And if a request is made to domain2.com the windows box with 192.168.1.200 should serve the requests.

Well the linux box will server the request but frward it to the windows box on 192.168.1.200

Quote:

Originally Posted by digitalnerds (Post 2912186)
Well knowing that port 80 is redirected to 192.168.1.100 (linux box) you want the linux to route the requests for domain2.com to 192.168.1.100 (ITSELF?) or to 192.68.1.200 which is the windows box.

Sorry, my mistake i meant domain2.com should point to 192.168.1.200

Quote:

Originally Posted by digitalnerds (Post 2912186)
So do you have any external IP's that are actually pointing to domain1.com and domain2.com?

I have two domains setup with their DNS pointing to my static IP. The IP that connects to the net.

So on my firewall i have only port 80 open which points to 192.168.1.100 which is the linux box, which i want requests to domain2.com to point to 192.168.1.200 without changing any ports.

Quote:

Originally Posted by digitalnerds (Post 2912186)
.. If yes why dont you redirect ports so all requests made to domain1.com are mapped to 192.168.1.100:80 while all requests made to domain2.com being mapped to 192.168.1.200:80.

Your help is much appreciated, its really hard to explain so i'm sorry if my explanation is slightly confusing. Probably better if i drew a picture...

Ant

digitalnerds 10-04-2007 02:51 AM

Hi there

I think (hope) i understood your request. If im right you will need to make use of either mod_proxy or mod_rewrite in your apache on the linux box to redirect. Since your router forwards all requests on port 80 to the linux box on port 80 you need to setup a VirtualHost in apache on the linux box for the domain2.com. The thing would look like:

For mod_rewrite
Code:

<VirtualHost 192.168.1.100>
    ServerName www.domain2.com
    ServerAlias domain2.com
    DocumentRoot /var/www
    RewriteEngine on
    RewriteRule  ^/$ \
      http://192.168.1.200 [P]
</VirtualHost>

For mod_proxy
Code:

<VirtualHost 192.168.1.100>
    ServerName www.domain2.com
    ServerAlias domain2.com
    ProxyPass        / http://192.168.1.200
    ProxyPassReverse / http://192.168.1.200
</VirtualHost>

Or you can combine both mod_rewrite and mod_proxy as:

Code:

<VirtualHost 192.168.1.100>
    ServerName www.domain2.com
    ServerAlias domain2.com
    ProxyPass        / http://192.168.1.200
    ProxyPassReverse / http://192.168.1.200
   
    RewriteEngine on
    RewriteRule  ^/$ http://192.168.1.200 [P]
</VirtualHost>

I do hope i understood your problem right and one of these solutions really helps you.

Regards
Andy

anthill 10-04-2007 03:28 AM

Thanks for your help.

I have tried using mod_rewrite but it seems to want to route the request to 192.168.1.200, which i want, this works fine when i'm inside the LAN but it doesn't seem to work outside, it also seems to put 192.168.1.200 in the URL rather than domain2.com.

I haven't looked at mod_proxy before, shall have a go...

In the meantime here is a diagram of my setup. Hope it explains it slightly better.

http://www.metasoma.com/temp/diagram.gif

By the way, when i say i couldn't get it to work, all i'm getting displayed from entering domain2.com is the linuux apache test page, not the IIS page.

Thanks for all your help!

Ant

anthill 10-04-2007 05:56 PM

You were right, i did just need to use the apache mod_rewrite. I can't believe it was that simple all along! I found this post that also helped me:

http://www.linuxquestions.org/questi...d.php?t=264864

Thanks for your help

Ant

anthill 10-08-2007 03:09 AM

Just a note for anyone who is attempting to achive the same as me:

I've noticed that if you use the mod_rewrite module it will forward the request to the windows box but only as an IP. Therefore if you want to set up multiple websites on the second machine they will not resolve to their domain name. If you use mod_proxy it will work with multiple websites, so use this instead.

Thanks

Ant


All times are GMT -5. The time now is 04:52 PM.