簡體   English   中英

Apache重寫然后代理通行證

[英]Apache Rewrite then Proxy Pass

我有一個apache服務器,在我們的DMZ中作為反向代理。 我們有一個外部服務,可以回發到此服務器上的特定URL。 現在需要將此服務回發到一個全新的應用程序,但這很可能在不久的將來再次發生變化,因為我們現在處於測試階段。

因此,要解決此問題,我正在嘗試接收傳入的回發請求/smsPostback.php ,並將其重寫為新的相對URL /SMSHandler/Process 這部分正在運作。

/SMSHandler在配置中直接定義,我都有一個ProxyPass指令將所有流量/SMSHandler代理到內部服務器。

這些是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

任何想法,為什么它永遠不會反向代理請求,而是嘗試(並失敗)在本地服務? 謝謝!

您需要向RewriteRule添加一個PT (PassThrough),以便apache獲取重寫的URI並通過URL處理管道將其傳回(以便mod_proxy可以處理它)。 該規則應如下所示:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM