2011-10-24 46 views
3

我有一個Apache/Passenger組合服務Rails 3.x和相同的組合服務Rails 2.x通過反向代理Passenger Standalone。我這樣做的原因是因爲Rails 2.x使用比Ruby/Passenger使用的Ruby更舊的Ruby版本。Apache反向代理可以排除某些文件類型嗎?

然而,在Rails 2.x應用程序中有一些Passenger Standalone不支持的應用程序。 (由黎紅麗在乘客討論小組確認)。 Hongli建議排除反向代理中的'php'位。

可以這樣做,如果是的話如何?


編輯說明如何使用反向代理服務器已經設置:

<VirtualHost *:80> 
    ServerName gtt 
    DocumentRoot /home/purvez/www/gtt/public 
    RailsEnv development 
    PassengerEnabled off 
    ProxyPass/http://127.0.0.1:3000/ 
    ProxyPassReverse/http://127.0.0.1:3000/ 
</VirtualHost> 

還怎麼一個普通的網站已經成立:

<VirtualHost *:80> 
    ServerName testapp 
    DocumentRoot /home/purvez/www/testapp/public 
    RailsEnv development 
</VirtualHost> 

回答

7

你可以使用ProxyPassMatch排除,如下:

<VirtualHost *:80> 
    ServerName gtt 
    DocumentRoot /home/purvez/www/gtt/public 
    RailsEnv development 
    PassengerEnabled off 
    ProxyPassMatch .*\.php$ ! 
    ProxyPass/http://127.0.0.1:3000/ 
    ProxyPassReverse/http://127.0.0.1:3000/ 
</VirtualHost> 

請注意,這會導致名爲gtt的虛擬主機中的所有'php位'從/home/purvez/www/gtt/public在本地提供服務。

希望這能讓你朝着正確的方向前進。

+0

現在這就是我喜歡的答案!非常感謝。就我的知識而言,請您解釋ProxyPassMatch實際執行的內容後的字符。我猜他們是RegExs,但我不完全確定。再次感謝。 – nexar

+0

@nexar:[apache文檔](http://httpd.apache.org/docs/2.2/mod/mod_proxy.html#proxypassmatch)可能比我更好地解釋它。 –