Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

mod_rewrite as reverse proxy not working with post method ...

Status
Not open for further replies.

dourix

MIS
Mar 17, 2004
9
LR

Hi guys,

I've seen this question asked several times but did not find any solution yet :-/

I'm trying to setup a reverse proxy with ProxyPass/ProxyReverse and with mod_rewrite, but both *don't work* when the proxied host uses a HTTP POST method, in which case it is redirecting instead of proxying.

Any solution ? any tips ?

--
DouRiX
 
Can you post your actual code? We do about 4 million+ post proxy's a day without incident.

 
with ProxyPass/ProxyReverse :

ProxyRequests off
ProxyPass / ProxyPassReverse /
and with mod_rewrite :

RewriteRule ^/(.*) [P]
RewriteCond /$1 -U
RewriteRule ^ /$1

both don't work (/w apache-1.3.26 and apache-2.0.48)

According to this link : it seems just impossible with only mod_proxy/apache-1.3,

I'm interested with your working config.

Thanks,
 
Hmm, if you use relative links you should be fine. Here is how I do my proxy's.

Code:
RewriteRule \.(gif|jpg|png|css|txt|cgi)$ - [last]
RewriteRule ^/cgi-bin - [last]

#####
# Check for trailing slash issue
#####
RewriteCond     /[URL unfurl="true"]www/www.site.com/html/%{SCRIPT_FILENAME}[/URL]    -d
RewriteCond     %{SCRIPT_FILENAME}      ^.*[^\/]$
RewriteRule ^(.*)$ $1/ [N]
# pass off everything but images to the heavy-weight server via proxy
RewriteRule ^/(.*)$ [URL unfurl="true"]http://www-internal.site.com:801/$1[/URL] [proxy]

You can see it at work at
Plenty of POST forms there going through the reverseproxy.
 
I don't see big differences between the rules :

<code>
RewriteRule ^/(.*)$ [proxy]

RewriteRule ^/(.*) [P]
</code>

Also I don't really understand what you mean by *relative links* ? my problem is that I can't touch the internal-site code,

I'm very curious to know why is it working for you,

Could you light more ?

Thanks,
 
Turn on RewriteLog to level 5 and see what requests are matching. This will tell you exactly where your request is going.

Post some of the related log lines here so we can take a look.
 
When I'm trying to proxy-reverse an imp horde site with the config below, and after the login (a post form), I am *redirected* to the actual imp url (
_config_ :

RewriteEngine on
RewriteLog /var/log/apache/mod_rewrite.log
RewriteLogLevel 5

CustomLog /var/log/apache/debug.log debug

RewriteRule ^/(.*) [P]
RewriteCond /$1 -U
RewriteRule ^ /$1

Here are the corresponding logs :

==> /var/log/apache/mod_rewrite.log <==
192.168.0.212 - - [24/Mar/2004:10:37:11 +0300] [my.proxy.com/sid#80ccac4][rid#81424cc/initial] (2) init rewrite engine with requested uri /horde/imp/redirect.php
192.168.0.212 - - [24/Mar/2004:10:37:11 +0300] [my.proxy.com/sid#80ccac4][rid#81424cc/initial] (3) applying pattern '^/(.*)' to uri '/horde/imp/redirect.php'
192.168.0.212 - - [24/Mar/2004:10:37:11 +0300] [my.proxy.com/sid#80ccac4][rid#81424cc/initial] (2) rewrite /horde/imp/redirect.php -> 192.168.0.212 - - [24/Mar/2004:10:37:11 +0300] [my.proxy.com/sid#80ccac4][rid#81424cc/initial] (2) forcing proxy-throughput with 192.168.0.212 - - [24/Mar/2004:10:37:11 +0300] [my.proxy.com/sid#80ccac4][rid#81424cc/initial] (1) go-ahead with proxy request proxy: [OK]
192.168.0.212 - - [24/Mar/2004:10:37:11 +0300] [my.proxy.com/sid#80ccac4][rid#808d1cc/initial/redir#1] (2) init rewrite engine with requested uri /horde/imp/redirect.php
192.168.0.212 - - [24/Mar/2004:10:37:11 +0300] [my.proxy.com/sid#80ccac4][rid#808d1cc/initial/redir#1] (3) applying pattern '^/(.*)' to uri '/horde/imp/redirect.php'
192.168.0.212 - - [24/Mar/2004:10:37:11 +0300] [my.proxy.com/sid#80ccac4][rid#808d1cc/initial/redir#1] (2) rewrite /horde/imp/redirect.php -> 192.168.0.212 - - [24/Mar/2004:10:37:11 +0300] [my.proxy.com/sid#80ccac4][rid#808d1cc/initial/redir#1] (2) forcing proxy-throughput with 192.168.0.212 - - [24/Mar/2004:10:37:11 +0300] [my.proxy.com/sid#80ccac4][rid#808d1cc/initial/redir#1] (1) go-ahead with proxy request proxy: [OK]

==> /var/log/apache/debug.log <==
192.168.0.212 - - [24/Mar/2004:10:37:14 +0300] "POST /horde/imp/redirect.php?Horde=05c33a73fb0d6ae1b27866809000d288 HTTP/1.1" 302 5 " "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5) Gecko/20031115 Debian/1.5-3.he-1" 10238 3
 
Thats horde, not mod_proxy. Horde redirects after login.

Change your horder redirect IP and you'll probably be ok.

Horde does not know that its behind a revers proxy.
 

the problem is that the application behind behaves like horde, and i do not have control of it :-/
 
And you won't. You can probably change the URL's horde is doing redirects with and force them to where you want them, I have to do this on other peoples apps all the time.

But this is not really a reverse proxy problem, its a horde config problem at this point.
 
shouldn't the rule below already do it ?

Code:
    RewriteCond /$1  -U
    RewriteRule ^[URL unfurl="true"]http://192.168.0.254/(.*)$[/URL] /$1

anyway, thanks for your answers, i'll dig more, do more tests and come back to you later,
 
Probably not, the horde redirect is not even hitting your proxy post redirect. Thats why your logs end at :

POST /horde/imp/redirect.php?

You need to get horde to redirect out to your proxy again so you can handle it.

Anyhow, good luck, I am most likely not comprehending your problem fully.
 

> Anyhow, good luck, I am most likely not comprehending your
> problem fully.

me neither :)

thanks,
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top