Apache Rewrite, then a proxy server

I have an Apache server that acts as a reverse proxy in our DMZ. We have an external service that returns to a specific URL on this server. Now for this service, there is a need for postback to a completely new application, but this is likely to change again in the near future, as we are in the testing phase right now.

So, to solve this problem, I try to take an incoming postback request /smsPostback.phpand put it into a new relative the URL, /SMSHandler/Process. This part works.

However, defined below in the config, I have a ProxyPass directive to proxy all traffic to /SMSHandlerthe internal server.

These are the new lines from the apache conf file:

RewriteRule ^/smsPostback.php$ /SMSHandler/Process 
##Proxy pass smshandler
ProxyPass /SMSHandler http://172.29.61.49:8080/SMSHandler
ProxyPassReverse /SMSHandler http://172.29.61.49:8080/SMSHandler

And these are the logs from the rewrite log:

172.29.61.49 - - [24/Jan/2012:18:43:36 --0500] [test.hidden.com/sid#5eace0][rid#446b770/initial] (2) init rewrite engine with requested uri /smsPostback.php
172.29.61.49 - - [24/Jan/2012:18:43:36 --0500] [test.hidden.com/sid#5eace0][rid#446b770/initial] (3) applying pattern '^/smsPostback.php$' to uri '/smsPostback.php'
172.29.61.49 - - [24/Jan/2012:18:43:36 --0500] [test.hidden.com/sid#5eace0][rid#446b770/initial] (2) rewrite '/smsPostback.php' -> '/SMSHandler/Process'
172.29.61.49 - - [24/Jan/2012:18:43:36 --0500] [test.hidden.com/sid#5eace0][rid#446b770/initial] (2) local path result: /SMSHandler/Process
172.29.61.49 - - [24/Jan/2012:18:43:36 --0500] [test.hidden.com/sid#5eace0][rid#446b770/initial] (2) prefixed with document_root to C:/hidden.com/SMSHandler/Process
172.29.61.49 - - [24/Jan/2012:18:43:36 --0500] [test.hidden.com/sid#5eace0][rid#446b770/initial] (1) go-ahead with C:/hidden.com/SMSHandler/Process [OK]

And this is the error log entry from apache:

[Tue Jan 24 18:43:36 2012] [error] [client 172.29.61.49] File does not exist: C:/fmfacilitymaintenance.com/SMSHandler

Any thoughts on why he never reverses proxy requests but tries (and fails) to serve it locally? Thank!

+5
source share
1 answer

You need to add PT(PassThrough) to your RewriteRule so that apache takes the rewritten URI and passes it back through the URL processing pipeline (so that mod_proxy can handle it). The rule should look like this:

RewriteRule ^/smsPostback.php$ /SMSHandler/Process [L,PT]
+14
source

All Articles