Can Apache Reverse Proxy exclude certain file types?

孤街醉人 提交于 2019-12-22 09:56:09

问题


I have an Apache/Passenger combo serving Rails 3.x and the same combo serving Rails 2.x via a reverse proxy to Passenger Standalone. The reason I'm doing this is because Rails 2.x uses an older version of Ruby than the Ruby used by the Apache/Passenger.

However there is a bit of php in the Rails 2.x app which Passenger Standalone cannot support. (Confirmed by Hongli Lai on the Passenger Discussion Group). Hongli suggests excluding the 'php' bits from the Reverse Proxy.

Can this be done, and if so how?


Edit to show how the Reverse proxy has been set up:

<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>

Also how an ordinary site has been set up:

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

回答1:


You could use ProxyPassMatch to exclude, as follows:

<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>

Note that this will cause all 'php bits' in the virtual host named gtt to be served locally from /home/purvez/www/gtt/public.

Hope this gets you moving in the right direction.



来源:https://stackoverflow.com/questions/7874277/can-apache-reverse-proxy-exclude-certain-file-types

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!