LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   need to proxy certain webpages to another port for php5 instance (https://www.linuxquestions.org/questions/linux-server-73/need-to-proxy-certain-webpages-to-another-port-for-php5-instance-607443/)

mtlhd 12-17-2007 04:16 PM

need to proxy certain webpages to another port for php5 instance
 
Does anyone know how to configure apache to proxy a webpage I made to forward to another port so it will run the php5 instance that islistening to that port ???

<directory> ?????????
<VirtualHost> ????????

one of those?

thanks!

-mtlhd
your resident linux noob

Shade 12-17-2007 06:54 PM

There are a couple ways to do this.

First would be to simply use a rewrite rule to tack on the corrected port. Something like this in .htaccess or the <VirtualHost> section:

Code:

RewriteEngine On
# Redirect to alt port
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ http://your.domain.com:8080/$1 [R,L]

Replace 8080 with your alternate port, and your.domain.com with, obviously, your domain.

Another method is to use mod_proxy and set up a reverse proxy. This is what you want to do if you need to run both instances, php4 and php5, and don't want visitors to see the alternate port in the URL.

Something like this, once you've installed and enabled mod_proxy:
Code:

ProxyRequests Off

<Proxy *>
Order deny,allow
Allow from all
</Proxy>

# Then add the following to the <VirtualHost> section of the site...

ProxyPass /foo http://foo.example.com:8080/bar
ProxyPassReverse /foo http://foo.example.com:8080/bar

Here's an excellent howto, although probably more thorough than you need.


All times are GMT -5. The time now is 03:14 AM.