LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices



Reply
 
Search this Thread
Old 04-02-2006, 06:04 AM   #1
johndmann
LQ Newbie
 
Registered: Mar 2006
Location: Texas
Distribution: Debian Sarge
Posts: 16

Rep: Reputation: 0
SOLVED: Subdomain->IP?


I have multiple computers on my LAN running Linux and Apache. I have a static IP, which goes through a firewalled router. The router is portforwarding to one computer, and Apache works great. There are no problems with that.

But... I want to have a subdomain - pc2.domain.com - which is served by a different computer on my LAN. Is it possible to tell the apache server at www.domain.com (192.168.1.11) to forward requests to pc2.domain.com (192.168.1.4)'s Apache installation?

I looked into mod_proxy, but setting it up the way that was suggested did not work. pc2.domain.com just times out in the browser.

Is this possible, or does anyone have a httpd.conf section I could use as a basis for figuring this one out?

**EDIT: Fiddling with some settings got mod_proxy to work... sortof... It works on the LAN by basically redirecting my browser to http://192.168.1.4 - my private IP. I don't want that to happen, because people outside the LAN will not be able to connect to it, so mod_proxy does not seem to be the solution

Last edited by johndmann; 04-03-2006 at 05:32 AM.
 
Old 04-02-2006, 02:32 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,415

Rep: Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968
mod_proxy at it's basic level is probably just what you want. the address you proxy to within apache is only relevant to apache itself, not the remote user, so you can happily just use a local hostname or IP and it won't care, but then you shouldn't be uisng ip addresses anyway.
 
Old 04-03-2006, 03:03 AM   #3
johndmann
LQ Newbie
 
Registered: Mar 2006
Location: Texas
Distribution: Debian Sarge
Posts: 16

Original Poster
Rep: Reputation: 0
I read up on the modproxy, and edited my post with my results. I will clarify here, though.

I read on apache.org that the basic layout of the mod_proxy should be just like the following:

<VirtualHost *:80>
#ProxyPreserveHost On
ServerName pc2.domain.com
ProxyPass / http://192.168.1.101:80
ProxyPassReverse / http://192.168.1.101:80/
</VirtualHost>

I put all of this in, and it first complained about "ProxyPreseveHost" is not a valid command, so I commented that out, and the rest went through like a charm. I was confused about that error, though, since it's even in the Apache documentation that it is a command.

After restarting Apache with this v-host configuration, if I open a browser and go to http://pc2.domain.com, my browser's address bar changes to http://192.168.1.101, and the site loads for me. However, since it changed to an internal IP address, I asked a friend to test the link out. He typed in http://pc2.domain.com on his browser, and it tried to load http://192.168.1.101 for him instead which, of course, fails.

It's close to what I want, and works on the LAN, but I can't get it to work for everyone else.
 
Old 04-03-2006, 03:37 AM   #4
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,415

Rep: Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968
it sounds like you've got a DNS looku pgoing on externally resolving to the internal address... that declaration is fine and mod_proxy does use internal addresses... a few things i'd look towards though. firstly drop the :80's in the proxy commands, and also stick a / on the end of the proxypass as that is wrong at the moment.
 
Old 04-03-2006, 04:59 AM   #5
johndmann
LQ Newbie
 
Registered: Mar 2006
Location: Texas
Distribution: Debian Sarge
Posts: 16

Original Poster
Rep: Reputation: 0
Well, I'll be! According to the apache docs, you're *supposed* to put the port designation in there, and to leave off the slash on the first entry, add it in the second :/ Well, not sure what difference it made internally, but removing the ports and adding the slash made it work perfectly!

Thank you!

Any idea why that ProxyPreserveHost On threw an error? From the looks of it, I didn't need it in the end, though.

Last edited by johndmann; 04-03-2006 at 05:01 AM.
 
Old 04-03-2006, 05:09 AM   #6
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,415

Rep: Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968
well i guess that putting the port couldn't posibbly hurt... just what you're used to i guess.

as the two declarations aren't symmetrical, translations will go wrong as a link proxied one way can be translated effectively in the other. I would expect that this inconsistency caused the LAN address to be interpretted wrongly by the front end server and passed back the the client.
 
  


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
Creating a subdomain? Spreegem Debian 7 02-06-2006 11:37 AM
ftp and subdomain unix20009876 Linux - Software 1 11-16-2005 11:59 AM
Apache 1.3.33 and subdomain fai Linux - Software 1 07-15-2005 04:49 AM
Subdomain help DoobyWho Linux - General 3 04-14-2003 07:51 PM
subdomain deepak Linux - Networking 2 03-01-2001 10:50 PM


All times are GMT -5. The time now is 10:18 AM.

Main Menu
Advertisement
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