[opensource] Network Question

Jim Dinan dinan at cse.ohio-state.edu
Tue Oct 25 11:27:44 EDT 2005


Michael Haig wrote:
> I'm working with a friend on setting up a few webservers and I was
> wondering if you open source gurus could lend a little insite. 
> Basically, we are trying to run two seperate webservers that are on a
> Lan together, through one Static IP.
> 
> A little diagram:
> 
> Internet (Static IP, multiple domains point to it) -> Cisco UBR Router
> -> Linksys Router (routing port 80 to .140) -> Switch -> Webservers
> (.140  (Apache 1.3) & .179 (Apache 2.0))
> 
> Right now I'm using a Proxy and ReverseProxy, in httpd.conf on the .140
> server to send certain domains to the .179 server, which works
> perfectly, except it's incredibly slow.  I was wondering if anyone knew
> a better (faster) way to do this.

You could always run the second webserver on a different port and 
redirect there from the first.  Doing an HTTP-EQUIV "refresh" isn't 
transparent to the users since they will see a URL with the new port.  I 
haven't tried this before, but it looks like might be able to use 
mod_rewrite to rewrite URLs transparently and direct users to the right 
port.

There is an example online here: 
http://rewrite.drbacchus.com/rewritewiki/VirtualHost

So, that example adapted to your setup might look something like:

RewriteEngine On
RewriteCond %{HTTP_HOST}   ^www\.server2\.com [NC]
RewriteCond %{SERVER_PORT} ^80$
RewriteRule ^/(.*)         http://www.server2.com:8080/$1 [L,R]

This says:
Condition 1: The hostname is www.server2.com [NC] = Case insensitive
Condition 2: The request was to port 80
Rewrite, and stash the second half of the URL in $1 and tack on the 
correct port number.  [L] says this is the last rewrite rule in this 
ruleset and [R] forces a 302 Redirect.

For reference on mod_rewrite I recommend Rich Bowen's slides from the 
presentation he gave at this year's Linux Fest: 
http://people.apache.org/~rbowen/presentations/mod_rewrite.pdf

Cheers,
- jim.


More information about the Opensource mailing list