Re: How to use different server based on the url ???
Brett Hutley <[email protected]>
| Newsgroups | gmane.comp.apache.mod-proxy |
|---|---|
| Message-ID | <[email protected]> |
Nicolas Brasseur wrote:
>Hello can anybody please tell me if it is possible to
>reroute requests to another web server based on the
>url used ...
>I have an apache web server on a machine, and a lotus
>domino server on another machine. I have a domain name
>loop.be pointing to a router that re-route requests
>addressed to the port 80 to the apache server. I would
>like that when the url is www.loop.be the HTTP
>requests are re-routed to the apache server (normal
>way) and when the url used is mail.loop.be the HTTP
>requests should be forwarded to the domino server.
>In other terms, is apache able to "forward" requests
>based on the url used ...
>
Yup, definitely. Use mod_rewrite and mod_proxy. You'll need to build a
version of apache with these compiled in or loaded as modules (since
they are not included by default). You want to set up a rewrite rule
with a regex that matches the address you want to proxy and get it to
handle the other stuff locally. I believe that you'll only be able to do
it with HTTP/1.1 requests since your rewrite rule will depend on having
a RewriteCond using the %{HTTP_HOST} variable.
I'm pretty much a mod_rewrite novice, but I'll make a quick stab at
solving the problem (although someone with more experience PLEASE chime
in at this port...):
RewriteEngine on
RewriteCond %{*HTTP_HOST*} ^mail.loop.be$
RewriteRule ^(.+) http://domino.server/$1 [P,L]
RewriteRule ^/(.*) - [L]
The first rewrite rule depends on the condition of the HTTP_Host being
mail.loop.be. It then proxies the request to your domino server and
stops rewriting. The second rule says to serve the remaining matches
locally.
HTH,
Brett