Mandriva Expert
The place where your Mandriva Linux system finds support

port forwarding to multiple webservers

+/- details
User dbelkie
Incident Number 24566
Date 2002/06/10 05:59
Status Incident closed
Paid No

Product 8.1
Architecture x86_32
Scope Networking

Products owned
Community Support question - to convert into a paid question, click here

Lines in bold below have not yet been seen by the customer - those in blue are from the customer

Username : Date : Action : Comments [ close all ]    
 
dbelkie : 10/06/02 05:59 AM : Incident created
-   Right now I have a linux box acting a gateway on my DSL connection. I have it doing port forwarding of port 80 to a web server on my internal LAN. I am in need of putting another webserver on the LAN, but am un-sure of how I can get the Linux box to know to forward domain1.com to server "b" and domain2.com to server "a"

Thoughts?
Thanks in advance!
Dan

 
Linux-phased : 10/06/02 12:12 PM : More info requested
-   Well for something like that you need either real static IP adresses(no
private network ones), but you don't have those.

Or you setup a DNS server for your private network.
But why are you doing it the complicated way, just setup a virtual host at the
webserver you have already running. So this webserver will jump into the
dirwctory:


/var/www/html/~domain1
/var/www/html/~domain2

if someone asks for www.domain1.com he will land -->/var/www/html/~domain1
if someone asks for www.domain2.com he will land -->/var/www/html/~domain2


Just read the apache documentation on how to setup a virtual hosts:

here is a sapmple:

<VirtualHost 127.0.0.1>
ServerName www.i-netlab.de
DocumentRoot /home/i-netlab.de/htdocs
DirectoryIndex index.html
ScriptAlias /cgi-bin/ /home/i-netlab.de/cgi-bin/
</VirtualHost>
<VirtualHost 127.0.0.1>
ServerName www.test.de
DocumentRoot /a_test
DirectoryIndex test.html
</VirtualHost>

If this resolves your problem please remember to close the ticket and rate
the expert that helped you otherwise the incident will still show up in the list.

Thanks Linux-phased

 
dbelkie : 10/06/02 04:43 PM : More info provided
-   Thanks Linux Phased!
The reason I need to add another web server ont he LAN, is because I need it to be a Windows 2000 for ASP. So I assume the Apache solution will not work. Could you explain the DNS solution a bit more?
Just set up a DNS with all the (private IP's) in it, and then point the webservers at those?

Thoughts?
Thanks again!
Dan

 
Linux-phased : 10/06/02 05:31 PM : More info requested
-   You can do the same with a IIS Webserver:-)

Just search for IIS virtual hosts, here is a example:


http://www.ezine.com/QandA/IIS2Domains.html

I don't think it's a good idea to eaxplain how to setup a DNS server if you
already don't have knowledge about basic Webserverfunctions. Setting up a DNS
server needs some good knowledge about linux and is not written down with a
couple of lines.

 
dbelkie : 10/06/02 05:37 PM : More info provided
-   Got ya, I have no problem with the DNS server set up, was just wondering how that works. Being someone would hit the Linux gatway, then because its a port 80 request it would be forwarded to the webserver. Im not sure how a enternal DNS would help the sitch?

I am aware that IIS has the same ability, but I need to to have 2 seperate webservers. one IIS and one apache.

Does that make sense?

Thanks again for all the help.
Dan

 
Linux-phased : 10/06/02 05:47 PM : More info requested
-   Well the DNS Server can also map your internal ips to hostnames, you get a
request for instance:

domain1 --> the dns server redirects this request to pc1 with IP 192.168.10
domain2 --> the dns server redirects this request to pc2 with IP 192.168.20

You cannot forward with iptables or ipchains, because they just care for Ips
you got to redirect by hostname with DNS.

So it is not be a problem if you know how to setup a DNS server.

 
dbelkie : 10/06/02 05:54 PM : More info provided
-   Ok I think I got ya!

I still use the Linux gateway PC and then I forward port 80 some place? or thake that out and the Linux gateway points at the internal DNS server to resolve domains?

d.

 
dbelkie : 10/06/02 07:56 PM : More info provided
-   Hey Linux-Phased!

Im sorry I wrote before I thought!

Yes this will work.. this is how I understand it... maybe you can tell me if im correct.

Leave the Linux gateway as it.
Build a Linux DNS box on the inside on a private IP.
Edit the gateway to forward port 53 reqests to the private IP on the DNS box.
Put all the hostnames and Private IP's in the DNS server.

Edit the domains whois record to point the primary DNS server to the IP of the Linx gateway (the only static IP)

All done!

Right?
d.

 
dbelkie : 10/06/02 07:59 PM : More info provided
-   Hey Linux-Phased!

Im sorry I wrote before I thought!

Yes this will work.. this is how I understand it... maybe you can tell me if im correct.

Leave the Linux gateway as it.
Build a Linux DNS box on the inside on a private IP.
Edit the gateway to forward port 53 reqests to the private IP on the DNS box.
Put all the hostnames and Private IP's in the DNS server.

Edit the domains whois record to point the primary DNS server to the IP of the Linx gateway (the only static IP)

All done!

Right?
d.

 
[email protected] : 10/06/02 09:44 PM : More info requested
-   I'd like to throw in another option (back to the multiple internal web
servers, specifically) that I was successful in getting working at a client
last week.

If you really need to have separate web servers, as was the case with my
client, running different configurations on different machines, what you
could do is have one of them be a sort of "master" webserver, with virtual
hosts, and those virtual hosts being "proxies" for the other webservers.

All external browsers would be hitting that "master" server, but the master
server would, in turn, be forwarding web stuff from the other servers.

An example config on the master server's httpd.conf file:
NameVirtualHost 192.168.0.10 {the internal IP address of the "master" server
<VirtualHost 192.168.0.10>
ServerName server2.mydomain.com {name of the server clients are hitting}
ServerAdmin {[email protected]}
ErrorLog {/var/log/httpd/whatever}
TransferLog {/var/log/httpd/whatever2}
ProxyPass / http://192.168.0.11/ {the internal IP address of the
server actually providing the pages}
</VirtualHost>

In the long list of LoadModules, uncomment the line
LoadModule proxy_module modules/libproxy.so

and in the long list of AddModules, uncomment the line
AddModule mod_proxy.c

Then restart your httpd:
service httpd restart

You don't actually have to do any other Proxy module configuration.

Linux-phased is, as always, providing sound advice, but my enthusiasm at
having got around some complications using this last week compells me to
share it with you.

Let me know if you need any clarifications.

Good luck,
DAM

 
[email protected] : 10/06/02 09:47 PM : More info requested
-   One final detail for my input:

Note that my virtual server/proxy suggestion will only work for external
users if you have registered distinct A-record or CNAME DNS records pointing
to your external IP address.

Likewise, this will only work for clients internal to your network if your
internal DNS resolution provides those A-record or CNAME DNS records
pointing to your webserver's internal IP address.

 
 
dbelkie : 17/07/02 10:10 PM : Incident closed
-  



This Incident is closed. It can not be edited anymore. You can create a new one by signing up/logging in your Mandriva Expert account.

  Mandriva  |  Contact  |  Legal  |  Privacy  |  Careers