You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by George Valpak <gv...@yahoo.com> on 2002/12/21 21:41:10 UTC

2 proxying and mod_perl questions

Hi -

I have 2 questions, one might be off topic for the list, so please be gentle about it - seems to have been a rough week for OT posters here.....


Anyway my situation is this:

I want to do a reverse proxy of an external site using Apache:

<VirtualHost prague>
ProxyRequests on
ProxyPass / http://www.externalsite.com
ProxyPassReverse / http://www.externalsite.com
ServerName prague
</VirtualHost>

This works fine AFICT except if there is a page on the remote site that has a form or other link that uses POST.

The maybe off-topic question is: Is this documented anywhere? I haven't been able to find a good explanation why this is. Is there a workaround? 

I should note that I am using mod_proxy rather than mod_rewrite because it is my (possibly incorrect) understanding that requests proxied via mod_rewrite will not end up in my local logs. I haven't actually tested that yet, but  in this case I strongly prefer to have a record of the request in the logs. If mod_rewrite would leave me a record in the logs and solve the POST issue, then that is probably an acceptable workaround.

Anyway, pointers to help or explanations on this question are welcomed.

More on topic for this list is this question:

I would like the local server to examine the HTML for the remote server and possibly modify it before sending it to the client. I would like to write a mod_perl handler for this, but I am not sure which phase I should do it at. 

[time passes ...] Oh wait, I see there is a section in the Eagle book (p 374) that shows how to do that - are there any gotchas or more modern examples I should know about?

Thanks in advance!

GV


Re: 2 proxying and mod_perl questions

Posted by Larry Leszczynski <la...@furph.com>.
Hi George -

> I want to do a reverse proxy of an external site using Apache:
> 
> <VirtualHost prague>
> ProxyRequests on

You will want to set "ProxyRequests off" for a reverse proxy, otherwise
someone could use you as a forward proxy to get to someplace else.


> ProxyPass / http://www.externalsite.com
> ProxyPassReverse / http://www.externalsite.com

Not sure if it matters, but might need a trailing slash on those, i.e.:
  ProxyPass        / http://www.externalsite.com/
  ProxyPassReverse / http://www.externalsite.com/


> ServerName prague
> </VirtualHost>
> 
> This works fine AFICT except if there is a page on the remote site
> that has a form or other link that uses POST.

Have you looked at the URL specified in the form ACTION to see if it is an
absolute URL?  For example, suppose I point my browser at
http://www.george.com/showform.html.  Your proxy then sends me the content
of http://www.externalsite.com/showform.html.  If the form on that page
POSTs to "http://www.externalsite.com/cgi-bin/form.cgi" (instead of
"/cgi-bin/form.cgi"), then when I submit I will go directly to
www.externalsite.com and bypass your proxy.  The same would be true of any
URL in the site that is specified absolute rather then relative.


> The maybe off-topic question is: Is this documented anywhere? I
> haven't been able to find a good explanation why this is. Is there a
> workaround?

You would need to rewrite any URLs in the page before you send it to the
browser, to either turn them into relative URLs, or to point them to
www.george.com instead of www.externalsite.com.  I'm pretty sure you can't
do that with mod_proxy or mod_rewrite alone (although I have seen people
do some crazy stuff with mod_rerwite).


> I should note that I am using mod_proxy rather than mod_rewrite
> because it is my (possibly incorrect) understanding that requests
> proxied via mod_rewrite will not end up in my local logs.

I have not found that to be the case.


Larry Leszczynski
larryl@furph.com