LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
Search this Thread
Old 10-03-2007, 03:36 PM   #1
anthill
LQ Newbie
 
Registered: Mar 2003
Posts: 11

Rep: Reputation: 0
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
 
Old 10-03-2007, 03:51 PM   #2
digitalnerds
Member
 
Registered: May 2007
Distribution: Debian
Posts: 103

Rep: Reputation: 15
Quote:
Originally Posted by anthill View Post
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 View Post
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
 
Old 10-03-2007, 06:11 PM   #3
anthill
LQ Newbie
 
Registered: Mar 2003
Posts: 11

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by digitalnerds View Post
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 View Post
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 View Post
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 View Post
.. 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
 
Old 10-04-2007, 02:51 AM   #4
digitalnerds
Member
 
Registered: May 2007
Distribution: Debian
Posts: 103

Rep: Reputation: 15
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
 
Old 10-04-2007, 03:28 AM   #5
anthill
LQ Newbie
 
Registered: Mar 2003
Posts: 11

Original Poster
Rep: Reputation: 0
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
 
Old 10-04-2007, 05:56 PM   #6
anthill
LQ Newbie
 
Registered: Mar 2003
Posts: 11

Original Poster
Rep: Reputation: 0
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
 
Old 10-08-2007, 03:09 AM   #7
anthill
LQ Newbie
 
Registered: Mar 2003
Posts: 11

Original Poster
Rep: Reputation: 0
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Routing incoming requests to different IP anthill Linux - Networking 1 09-18-2007 11:37 PM
Routing requests from the server, thru an IP other than the Main SirTristan Linux - Newbie 4 12-08-2006 07:36 AM
Routing between internal subnets teamchachi Linux - Networking 2 05-11-2005 07:21 AM
Port Forwarding not working for Internal requests angelgw Linux - Networking 2 06-29-2003 12:42 AM
Internal Routing Saris Linux - Newbie 12 06-24-2003 11:30 PM


All times are GMT -5. The time now is 09:25 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration