Re: front end proxy and virtual hosts

2000-04-10 Thread Vivek Khera

> "EC" == Eric Cholet <[EMAIL PROTECTED]> writes:

EC> do you setup virtual hosts on the backend server? Different IPs, or
EC> different ports? Or just a flat url space, using mod_rewrite on the
EC> front-end to translate the urls?

I think I posted this example earlier.  This is just a snippet of the
relevant portions of the front/back end virtual configs.  It is not a
cookie-cutter example!

Basically, I use unique port number virtuals on the back-ends (so I
can redirect to localhost: bypassing some networking cruft) and
name-based virtuals on the front end, though any technique on the
front end will do.

I set "Port 80" on the back-end so that any redirects don't get sent
directly to the back-end.  Sometimes I also bind tightly to address
127.0.0.1 to prevent any outside connections when the two are on the
same box.

Stas, feel free to incorporate this example.

front end:


  ServerName www.morebusiness.com
  ServerAlias morebusiness.com
  RewriteEngine On
  RewriteOptions 'inherit'
  # handle GIF and JPG images directly
  RewriteRule \.(gif|jpg|png|css|txt|cgi)$ - [last]
  RewriteRule ^/cgi-bin - [last]
  # pass off everything but images to the heavy-weight server via proxy
  RewriteRule ^/(.*)$ http://localhost:4077/$1 [proxy]

  Alias /_homepage /web/morebusiness/docs/_homepage-default
  Alias /_pageparts /web/morebusiness/docs/_pageparts-default




  ServerName govcon.morebusiness.com
  RewriteEngine On
  RewriteOptions 'inherit'
  # handle GIF and JPG images directly
  RewriteRule \.(gif|jpg|png|css|txt|cgi)$ - [last]
  RewriteRule ^/cgi-bin - [last]
  # pass off everything but images to the heavy-weight server via proxy
  RewriteRule ^/(.*)$ http://localhost:4078/$1 [proxy]

  Alias /_homepage /web/morebusiness/docs/_homepage-govcon
  Alias /_pageparts /web/morebusiness/docs/_pageparts-govcon



back-end:

Port 80

Listen 4077

  ServerName www.morebusiness.com
  Port 80
  DirectoryIndex index.brc index.ibrc index.shtml index.html

  ###
  #
  # Get "real" remote IP address from Proxy and set it as our connection's
  # IP address so logging, etc., use that IP address.  Uses mod_perl handler.
  # For some reason, must be set per-virtual host.
  #
  ###

  PerlPostReadRequestHandler My::ProxyRemoteAddr

  Alias /_homepage /web/morebusiness/docs/_homepage-default
  Alias /_pageparts /web/morebusiness/docs/_pageparts-default



Listen 4078

  ServerName govcon.morebusiness.com
  Port 80

  DirectoryIndex index.brc index.ibrc index.shtml index.html

  PerlPostReadRequestHandler My::ProxyRemoteAddr

  Alias /_homepage /web/morebusiness/docs/_homepage-govcon
  Alias /_pageparts /web/morebusiness/docs/_pageparts-govcon






RE: front end proxy and virtual hosts

2000-04-10 Thread Eric Cholet

> EC> do you setup virtual hosts on the backend server? Different IPs, or
> EC> different ports? Or just a flat url space, using mod_rewrite on the
> EC> front-end to translate the urls?
> 
> I think I posted this example earlier.  This is just a snippet of the
> relevant portions of the front/back end virtual configs.  It is not a
> cookie-cutter example!
> 
> Basically, I use unique port number virtuals on the back-ends (so I
> can redirect to localhost: bypassing some networking cruft) and
> name-based virtuals on the front end, though any technique on the
> front end will do.
> 
> I set "Port 80" on the back-end so that any redirects don't get sent
> directly to the back-end.  Sometimes I also bind tightly to address
> 127.0.0.1 to prevent any outside connections when the two are on the
> same box.

Vivek,

Thanks a lot for your input.

>   ###
>   #
>   # Get "real" remote IP address from Proxy and set it as our connection's
>   # IP address so logging, etc., use that IP address.  Uses mod_perl handler.
>   # For some reason, must be set per-virtual host.
>   #
>   ###
> 
>   PerlPostReadRequestHandler My::ProxyRemoteAddr

This is no longer necessary with mod_perl >= 1.22, i.e. it can be put
in the main server config and will be inherited (merged) in virtual hosts.

--
Eric




Re: front end proxy and virtual hosts

2000-04-10 Thread Tom Mornini

On Mon, 10 Apr 2000, Eric Cholet wrote:

> The front-end light server, serving static requests and proxying
> dynamic requests to a back-end modperl server, is well documented,
> except in the case of virtual hosts. How do you do it? Specifically,
> do you setup virtual hosts on the backend server? Different IPs, or
> different ports? Or just a flat url space, using mod_rewrite on the
> front-end to translate the urls?

I use static IP's and virtualhosts on the front-ends (we're investigating
using our Foundry ServerIron load balancer to rewrite the HTTP headers to
allow for name-based virtual servers on the front-ends).

mod_rewrite handles proxying the dynamic requests and apparently mod_proxy
automatically adds the correct headers for name-based virtual hosts on the
back end.

This all takes a while to setup, but it works flawlessly once it is done.

-- 
-- Tom Mornini
-- InfoMania Printing and Prepress




Re: front end proxy and virtual hosts

2000-04-12 Thread Ask Bjoern Hansen

On Mon, 10 Apr 2000, Eric Cholet wrote:

Port based backend servers is the easiest.

Use

Port 80
Listen 127.0.0.1:8088 (or whatever)
Listen 127.0.0.1:8089 ...

in your backend setup to make sure it never reveals the real port and only
listens on the loopback interface (if that's what you want).

Then the frontend can be setup in any way you like and proxy the requests
to the appropiate port on the backend.


 - ask

-- 
ask bjoern hansen - 
more than 70M impressions per day, 




Re: front end proxy and virtual hosts

2000-04-12 Thread Vivek Khera

I just ran into a bit of a conflict with Alias and Rewrite on my front
end.

Given that I have multiple virtual hosts serving up the same content
using a slightly different set of graphics and templates, the easy way
is to "Alias /_pageparts /real/page/parts/directory" and make the
alias different for each virtual host.  Then every document refers to
/_pageparts/XXX.yyy for the component it wants, and the proper one
based on the virtual host is used.

Something like this:


  ServerName next.morebusiness.com
  RewriteEngine On
  RewriteOptions 'inherit'
  # handle GIF and JPG images directly
  RewriteRule \.(gif|jpg|png|css|txt|cgi)$ - [last]
  RewriteRule ^/cgi-bin - [last]
  # pass off everything but images to the heavy-weight server via proxy
  RewriteRule ^/(.*)$ http://localhost:4079/$1 [proxy]

  DocumentRoot /web/morebusiness/nextdocs

  Alias /_pageparts /web/morebusiness/nextdocs/_pageparts-default



and on the back-end

Listen 4079

  ServerName next.morebusiness.com
  Port 80

  DocumentRoot /web/morebusiness/nextdocs

  DirectoryIndex index.brc index.shtml index.html

  Alias /_pageparts /web/morebusiness/nextdocs/_pageparts-default


One of the objects inside _pageparts-default is PAGEFOOT.shtml.  If I
do a 

lynx -source 'http://next.morebusiness.com/_pageparts-default/PAGEFOOT.shtml'

The page comes across fine.  If I do

lynx -source 'http://next.morebusiness.com/_pageparts/PAGEFOOT.shtml'

I get the page dumped raw.  That is, the SSI constructs are ignored.

If I enable .shtml files to be server-parsed on the front-end server,
then both return the processed result.  This is my work-around.

This leads me to believe that the Rewrite engine is ignored when an
Alias kicks in, otherwise the *.shtml files would be bounced back to
the back-end server where they get properly expanded.  Normally, this
is ok for me since everything else in the aliased directory is an
image which I want the front end to handle.

Has this bitten anyone else?  Stas, I think you should mention this in
the guide somehow as something to watch out for when using the proxy
front-end.  The Rewrite rules are ignored when an Alias expands the
URI, or so it seems from where I sit.

-- 
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Vivek Khera, Ph.D.Khera Communications, Inc.
Internet: [EMAIL PROTECTED]   Rockville, MD   +1-301-545-6996
PGP & MIME spoken herehttp://www.kciLink.com/home/khera/



Re: front end proxy and virtual hosts

2000-04-12 Thread Ask Bjoern Hansen

On Wed, 12 Apr 2000, Vivek Khera wrote:

[...]
> Has this bitten anyone else?  Stas, I think you should mention this in
> the guide somehow as something to watch out for when using the proxy
> front-end.  The Rewrite rules are ignored when an Alias expands the
> URI, or so it seems from where I sit.

They're both Trans handlers in the normal case. So if mod_alias runs first
and matches it will return OK and mod_rewrite won't see the request.
 
So it shouldn't be a surprise. :)

I think the advice to give is to not mix them. mod_rewrite does everything
mod_alias does - (except for ScriptAlias which is not really relevant on
this list anyway) - so if you need mod_rewrite for a set of urls, use it
exclusively.


 - ask

-- 
ask bjoern hansen - 
more than 70M impressions per day, 




Re: front end proxy and virtual hosts

2000-04-12 Thread Vivek Khera

> "ABH" == Ask Bjoern Hansen <[EMAIL PROTECTED]> writes:

ABH> mod_alias does - (except for ScriptAlias which is not really relevant on

Duh.  Ya know, sometimes you stare and stare and stare and it doesn't
come to you.  I don't even need mod_alias at all...

Thanks!




RE: front end proxy and virtual hosts

2000-04-13 Thread Eric Cholet

> This leads me to believe that the Rewrite engine is ignored when an
> Alias kicks in, otherwise the *.shtml files would be bounced back to
> the back-end server where they get properly expanded.  Normally, this
> is ok for me since everything else in the aliased directory is an
> image which I want the front end to handle.
> 
> Has this bitten anyone else?  Stas, I think you should mention this in
> the guide somehow as something to watch out for when using the proxy
> front-end.  The Rewrite rules are ignored when an Alias expands the
> URI, or so it seems from where I sit.

Actually I got bitten by the opposite, my Alias directives are ignored
when Rewrite kicks in. I assume it depends on the Apache module order,
and as Ask explained when one trans handler returns OK the other is
of course ignored, so I too had to convert my Alias statements to
rewrite rules.

--
Eric




Re: front end proxy and virtual hosts

2000-04-15 Thread Matt Carothers



On Mon, 10 Apr 2000, Eric Cholet wrote:

> The front-end light server, serving static requests and proxying
> dynamic requests to a back-end modperl server, is well documented,
> except in the case of virtual hosts. How do you do it?

On the front end:


DocumentRoot /vhosts/customer
ProxyPass/perl/ http://localhost/customer/perl/
ProxyPassReverse /perl/ http://localhost/customer/perl/


On the back end:

DocumentRoot /vhosts
BindAddress 127.0.0.1


SetHandler perl-script
PerlHandler Apache::Registry # Or whatever
PerlSendHeader  On
Options +ExecCGI


- Matt




[summary] Re: front end proxy and virtual hosts

2000-04-15 Thread Stas Bekman


=head1 Front-end Back-end Proxying with Virtual Hosts

This section explains a configuration setup for proxying your back-end
mod_perl servers when you need to use Virtual Hosts.

The approach is to use unique port number for each virtual host at the
back-end server, so you can redirect from the front-end server to
localhost::1234, and name-based virtual servers on the front end, though
any technique on the front-end will do. 

If you run the front-end and the back-end servers on the same machine
you can prevent any direct outside connections to the back-end server
if you bind tightly to address C<127.0.0.1> (I) as you will
see in the following configuration example.

The front-end (light) server configuration:

  
ServerName www.example.com
ServerAlias example.com
RewriteEngine On
RewriteOptions 'inherit'
RewriteRule \.(gif|jpg|png|txt)$ - [last]
RewriteRule ^/(.*)$ http://localhost:4077/$1 [proxy]
  

  
ServerName foo.example.com
RewriteEngine On
RewriteOptions 'inherit'
RewriteRule \.(gif|jpg|png|txt)$ - [last]
RewriteRule ^/(.*)$ http://localhost:4078/$1 [proxy]
  

The above front-end configuration handles two virtual hosts:
I and I. The two setups are almost
identical.

The front-end server will handle files with the extensions I<.gif>,
I<.jpg>, I<.png> and I<.txt> internally, the rest will be proxified to
be handled by the back-end server.

The only difference between the two virtual hosts settings is that the
former rewrites requests to the port C<4077> at the back-end machine
and the latter to the port C<4078>.

The back-end (heavy) server configuration:

  Port 80
  
  PerlPostReadRequestHandler My::ProxyRemoteAddr
  
  Listen 4077
  
ServerName www.example.com
Port 80
DirectoryIndex index.shtml index.html
  
  
  Listen 4078
  
ServerName foo.example.com
Port 80
DirectoryIndex index.shtml index.html
  

The back-end server knows to tell which virtual host the request is
made to, by checking the port number the request was proxified to and
using the appropriate virtual host section to handle it.

We set S<"Port 80"> so that any redirects don't get sent directly to
the back-end port.

To get the I remote IP addresses from proxy, the
L
handler is used based on the C Apache module.
Prior to mod_perl 1.22+ this setting must have been set per-virtual
host, since it wasn't inherited by the virtual hosts.

The following configuration is yet another useful example showing the
other way around. It specifies what to be proxified and than the rest
is served by the front end:

  RewriteEngine on
  RewriteLogLevel   0
  RewriteRule   ^/(perl.*)$  http://127.0.0.1:8052/$1   [P,L]
  RewriteRule   ^proxy:.*   - [F]
  ProxyRequests on
  NoCache   *
  ProxyPassReverse  /  http://www.example.com/

So we don't have to specify the rule for the static object to be
served by the front-end as we did in the previous example to handle
files with the extensions I<.gif>, I<.jpg>, I<.png> and I<.txt>
internally.



__
Stas Bekman | JAm_pH--Just Another mod_perl Hacker
http://stason.org/  | mod_perl Guide  http://perl.apache.org/guide 
mailto:[EMAIL PROTECTED]  | http://perl.orghttp://stason.org/TULARC/
http://singlesheaven.com| http://perlmonth.com http://sourcegarden.org
--





Re: [summary] Re: front end proxy and virtual hosts

2000-04-17 Thread Vivek Khera

Looks good; I'd recommend keeping *.html files on the front-end as
well, since they tend to be static, and also any traditional *.cgi
since they don't need mod_perl's bloat on the fork/exec.

Also, specifying "Port 80" inside each virtual on the back-end is not
necessary, though perhaps setting a new DocumentRoot might make sense.


Perhaps this paragraph:

If your server is configured to run traditional CGI's as well as
mod_perl CGI programs, then it would be beneficial to configure the
front-end server to run the traditional CGI's directly.  This can be
done by altering the C rewrite rule to add C<|cgi> at
the end, or adding a new rule to handle all C locations
locally.  Similarly, static HTML pages can be served by the front-end
server by adding C<|html> to the rule.

-- 
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Vivek Khera, Ph.D.Khera Communications, Inc.
Internet: [EMAIL PROTECTED]   Rockville, MD   +1-301-545-6996
PGP & MIME spoken herehttp://www.kciLink.com/home/khera/