2012-01-25 11 views
5

DMZのリバースプロキシとして動作するApacheサーバーがあります。このサーバー上の特定のURLにポストバックする外部サービスがあります。このサービスは今では全く新しいアプリケーションにポストバックする必要がありますが、現在テスト段階に入っているため、近いうちにこの機能が再び変更される可能性があります。Apacheのリライトとプロキシのパス

これを解決するには、受信ポストバック要求/smsPostback.phpを取得し、新しい相対URLの/SMSHandler/Processに書き換えようとしています。この部分は機能しています。

ただし、configのすぐ下に定義されていますが、内部サーバーに/SMSHandlerへのすべてのトラフィックをプロキシするProxyPassディレクティブがあります。

これらは、Apacheのconfファイルからの新しいラインです:

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 

が、これらは書き換えログからのログです:

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] 

そして、これは、Apacheのエラー・ログ項目です:

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

なぜそれがリバースしないのかについての考えは、リクエストを代理処理するのではなく、むしろそれをローカルで提供するか?ありがとう!

答えて

14

Apacheが書き換えられたURIを受け取り、それをURL処理パイプライン(mod_proxyが処理できるように)に戻すように、PT(PassThrough)をRewriteRuleに追加する必要があります。ルールは次のようになります。

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

ありがとうございました!それはそれをした! – Matt

+2

あなたは「最後」を削除できます。それはパススルーhttp://httpd.apache.org/docs/2.2/rewrite/flags.html#flag_ptに暗示されています – oberhamsi

関連する問題