You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Sai A <ar...@gmail.com> on 2010/11/08 18:44:54 UTC

[users@httpd] mass proxying via mod_rewrite

Hi Apache users/experts,

I am trying to achieve proxying using mod_rewrite. I am trying to do the
following mappings:
Let www.company.com/foo/bar remain as such
Let all special subdomains.company.com/foo/bar remain as such
Proxy www.client1.com/admin to http://admin.company.com/client1name
Proxy www.client1.com to http://clients.company.com/client1name

admin.company.com and clients.company.com are externally accessible on the
internet and for anyone accessing them using those URLs should still work
(backward compatible). This is the httpd.conf file that I have written.

1) Is this approach right? Would the following also achieve the
functionality achieved by ProxyPassReverse of mod_proxy?

# LoadModule directives for mod_rewrite, mod_proxy and mod_proxy_http

RewriteEngine on
UseCanonicalName off

RewriteMap    lowercase    int:tolower
RewriteMap    clients      txt:/path/to/vhost.map

# If it is the main company site, then no looking up required.
RewriteCond %{HTTP_HOST}   ^(www)?\.company\.com [NC]
RewriteRule ^/(.*)         http://www.company.com/$1 [L]

# Don't map any of the special company subdomains
RewriteCond %{HTTP_HOST}   ^special\.company\.com [NC]
RewriteRule ^/(.*)         http://special.company.com/$1 [L]
# Do the above for other subdomains that should not be touched

# Rules for mapping client admin sites of the form
# www.client1.com/admin/xyz to http://admin.company.com/clientname/xyz

RewriteCond   %{HTTP_HOST}    !^$
RewriteCond   %{REQUEST_URI}  ^/admin/.*
RewriteCond   ${lowercase:%{HTTP_HOST}}  ^(.+)$
RewriteCond   ${clients:%1}  ^(.+)$
RewriteRule   ^/admin/(.*)$    http://admin.company.com/%1/$1 [P,L]

# Rules for mapping client sites of the form
# www.client1.com/foo to http://clients.company.com/clientname/foo

RewriteCond   %{HTTP_HOST}  !^$
RewriteCond   ${lowercase:%{HTTP_HOST}}  ^(.+)$
RewriteCond   ${clients:%1}  ^(.+)$
RewriteRule   ^/(.*)$    http://clients.company.com/%1/$1 [P,L]

# Rules so that older client URLs work
This is an auxiliary question: 2) How can I do this?

My vhost.map file is as follows:

www.client1.com client1name
www.client2.com client2name
# ...
www.clientN.com clientNname

Please let me know if this approach would work... if there are some caveats,
I'd like to know them as well.

Thanks in advance,
Sai

Re: [users@httpd] mass proxying via mod_rewrite

Posted by Sai A <ar...@gmail.com>.
Hi Apache users/experts,

1) Is there an equivalent of ProxyPassMatch for Apache 2.0? (I don't have
the option to upgrade to 2.2).

2) While ProxyPassMatch seems to satisfy half my problem, I am wondering how
I can implement the following:

Proxy www.clientX.com to http://clients.company.com/clientXname (but the
main company URL shouldn't be proxied).

3) Is the following allowed?
ProxyPass http://www.company.com !

Any inputs or suggestions on my original mail are appreciated.

On Mon, Nov 8, 2010 at 11:37 PM, Sai A <ar...@gmail.com> wrote:

> Hey Nick,
>
> Thanks for the reply. I didn't know about ProxyPassMatch. I am using Apache
> 2.0 (I forgot to mention that in my original mail) and I couldn't see
> ProxyPassMatch in that. I however found a ProxyMatch directive in that,
> would that work for this need? I'd have about 5k client URLs.
>
>
> On Mon, Nov 8, 2010 at 11:23 PM, Nick Kew <ni...@webthing.com> wrote:
>
>> On Mon, 8 Nov 2010 23:14:54 +0530
>> Sai A <ar...@gmail.com> wrote:
>>
>> > Hi Apache users/experts,
>> >
>> > I am trying to achieve proxying using mod_rewrite.
>>
>> That seems to be your mistake.
>>
>>  I am trying to do the
>> > following mappings:
>> > Let www.company.com/foo/bar remain as such
>> > Let all special subdomains.company.com/foo/bar remain as such
>> > Proxy www.client1.com/admin to http://admin.company.com/client1name
>> > Proxy www.client1.com to http://clients.company.com/client1name
>>
>> Keep it simple.  A single ProxyPassMatch does that.
>>
>> --
>> Nick Kew
>>
>> ---------------------------------------------------------------------
>> The official User-To-User support forum of the Apache HTTP Server Project.
>> See <URL:http://httpd.apache.org/userslist.html> for more info.
>> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>>   "   from the digest: users-digest-unsubscribe@httpd.apache.org
>> For additional commands, e-mail: users-help@httpd.apache.org
>>
>>
>

Re: [users@httpd] mass proxying via mod_rewrite

Posted by Sai A <ar...@gmail.com>.
Hey Nick,

Thanks for the reply. I didn't know about ProxyPassMatch. I am using Apache
2.0 (I forgot to mention that in my original mail) and I couldn't see
ProxyPassMatch in that. I however found a ProxyMatch directive in that,
would that work for this need? I'd have about 5k client URLs.


On Mon, Nov 8, 2010 at 11:23 PM, Nick Kew <ni...@webthing.com> wrote:

> On Mon, 8 Nov 2010 23:14:54 +0530
> Sai A <ar...@gmail.com> wrote:
>
> > Hi Apache users/experts,
> >
> > I am trying to achieve proxying using mod_rewrite.
>
> That seems to be your mistake.
>
>  I am trying to do the
> > following mappings:
> > Let www.company.com/foo/bar remain as such
> > Let all special subdomains.company.com/foo/bar remain as such
> > Proxy www.client1.com/admin to http://admin.company.com/client1name
> > Proxy www.client1.com to http://clients.company.com/client1name
>
> Keep it simple.  A single ProxyPassMatch does that.
>
> --
> Nick Kew
>
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>   "   from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>

Re: [users@httpd] mass proxying via mod_rewrite

Posted by Nick Kew <ni...@webthing.com>.
On Mon, 8 Nov 2010 23:14:54 +0530
Sai A <ar...@gmail.com> wrote:

> Hi Apache users/experts,
> 
> I am trying to achieve proxying using mod_rewrite.

That seems to be your mistake.

 I am trying to do the
> following mappings:
> Let www.company.com/foo/bar remain as such
> Let all special subdomains.company.com/foo/bar remain as such
> Proxy www.client1.com/admin to http://admin.company.com/client1name
> Proxy www.client1.com to http://clients.company.com/client1name

Keep it simple.  A single ProxyPassMatch does that.

-- 
Nick Kew

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org