You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Ron Arts <ro...@neonova.nl> on 2006/05/07 00:42:18 UTC

[users@httpd] reverse proxying to dynamically determined hosts

Hi,

I am trying to accomplish the following:

translate

   http://<myhost>/device/<anotherhost>/pathinfo

to a reverse proxy request to

   http://<anotherhost>/pathinfo

ProxyPass and ProxyReversePass are no good obviously,
so I am experimenting with mod_rewrite. But this:

<Directory /usr/local/prod/web/html>
   RewriteEngine on
   RewriteRule ^dev/([0-9.]*)/(.*)  http://$1/$2 [P]
</Directory>


does not work. In fact I can't even get

RewriteRule ^dev/192.168.170.212/(.*)  http://192.168.170.212/$1 [P]

to work, because it redirects instead of proxies...
How would redirects from the remote host be handled in this case?

Thanks for any insights.

Ron




Re: [users@httpd] reverse proxying to dynamically determined hosts

Posted by Krist van Besien <kr...@gmail.com>.
On 5/7/06, Ron Arts <ro...@neonova.nl> wrote:

> thanks for the tip. I did that and it showed that the proxying worked,
> but the remote server threw me a redirect, and my browser followed that
> and ended up bypassing the reverse proxy!

Another tip: Get Firefox (if you haven't got it allready) and the
HTTPHeaders plugin. That way you can see everything that gets passed
between your browser and the server. Great for catching problems
caused by unexpected redirects.


Krist

--
krist.vanbesien@gmail.com
Solothurn, Switzerland

---------------------------------------------------------------------
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] reverse proxying to dynamically determined hosts

Posted by Ron Arts <ro...@neonova.nl>.
Krist van Besien wrote:
> On 5/7/06, Ron Arts <ro...@neonova.nl> wrote:
>> Hi,
>>
>> I am trying to accomplish the following:
>>
>> translate
>>
>>    http://<myhost>/device/<anotherhost>/pathinfo
>>
>> to a reverse proxy request to
>>
>>    http://<anotherhost>/pathinfo
>>
>> ProxyPass and ProxyReversePass are no good obviously,
>> so I am experimenting with mod_rewrite. But this:
>>
>> <Directory /usr/local/prod/web/html>
>>    RewriteEngine on
>>    RewriteRule ^dev/([0-9.]*)/(.*)  http://$1/$2 [P]
>> </Directory>
>>
>>
>> does not work. In fact I can't even get
>>
>> RewriteRule ^dev/192.168.170.212/(.*)  http://192.168.170.212/$1 [P]
>>
>> to work, because it redirects instead of proxies...
>> How would redirects from the remote host be handled in this case?
> 
> You have a [P] at the end. So it is supposed to proxy, and not to
> redirect. If your server however does redirect than there might be
> something else in your config doing that.
> 
> Have you tried running with a rewrite log?
> 

Krist,

thanks for the tip. I did that and it showed that the proxying worked,
but the remote server threw me a redirect, and my browser followed that
and ended up bypassing the reverse proxy!

So now I do it like this:

ProxyPassReverse /dev/ http://

<Directory /usr/local/prod/web/html>
   RewriteEngine on
   RewriteRule ^dev/([0-9.]*)/(.*)  http://$1/$2 [P]
</Directory>

And amazingly enough this totally works!

Boy do I love the Apache developers ;-)


Thanks,
Ron

> Krist
> 
> 
> -- 
> krist.vanbesien@gmail.com
> Solothurn, Switzerland
> 
> ---------------------------------------------------------------------
> 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
> 


---------------------------------------------------------------------
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] reverse proxying to dynamically determined hosts

Posted by Krist van Besien <kr...@gmail.com>.
On 5/7/06, Ron Arts <ro...@neonova.nl> wrote:
> Hi,
>
> I am trying to accomplish the following:
>
> translate
>
>    http://<myhost>/device/<anotherhost>/pathinfo
>
> to a reverse proxy request to
>
>    http://<anotherhost>/pathinfo
>
> ProxyPass and ProxyReversePass are no good obviously,
> so I am experimenting with mod_rewrite. But this:
>
> <Directory /usr/local/prod/web/html>
>    RewriteEngine on
>    RewriteRule ^dev/([0-9.]*)/(.*)  http://$1/$2 [P]
> </Directory>
>
>
> does not work. In fact I can't even get
>
> RewriteRule ^dev/192.168.170.212/(.*)  http://192.168.170.212/$1 [P]
>
> to work, because it redirects instead of proxies...
> How would redirects from the remote host be handled in this case?

You have a [P] at the end. So it is supposed to proxy, and not to
redirect. If your server however does redirect than there might be
something else in your config doing that.

Have you tried running with a rewrite log?

Krist


--
krist.vanbesien@gmail.com
Solothurn, Switzerland

---------------------------------------------------------------------
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