LxCenter HyperVM & Kloxo Support

Forum



Members   Search      Help    Register    Login    Home
Home » LxCenter » GNU/Linux Help » Debian Apache2 as reverse proxy to Debian Apache2
Debian Apache2 as reverse proxy to Debian Apache2 [message #91159] Thu, 17 November 2011 22:24 Go to next message
shazar is currently offline shazar  United States
Messages: 1856
Registered: May 2011
Grandmaster
LxCenter Core Team Member
LxCenter Representative
Instead of using a non-distro webserver as a reverse proxy, I looked in to doing this purely with Apache2. Debian made this easy, but will also look into it with CentOS.

The idea is that a light-weight apache2 would listen on eth0 and server static content and if a request for a php page is made, it sends it to the heavy-weight apache2.

In Debian the init.d script is written to use its own name to find the conf files. This makes running 2 apache2 instances very easy.

cp /etc/init.d/apache2 /etc/init.d/apache2-light
cp -r /etc/apache2 /etc/apache2.bak
cp -r /etc/apache2 /etc/apache2-light
mkdir /var/log/apache2-light/
touch /var/log/apache2-light/error.log

You then have to edit the apache2 ports.conf and virtual host confs to listen only on 127.0.0.1.
Do the same for apache2-light, but use your external IP address.
Set the reverse proxy from apache2-light to send only php requests to 127.0.0.1.
Disable mod_php on apache2-light.
Enable APC on php.

With 1GB of memory and a heavy PHP ( apache2 uses 50 MB with APC enabled), I set my apache2 to 15 clients and my apache2-light to 50. Also I can now enable Keep Alive on the light.

My next goal is to have the light use worker, though the heavy must always use prefork to work well with PHP.

Any one interested in a full write up and will try this out?


https://www.mercuryvps.com
HyperVM Xen VPS hosting
Re: Debian Apache2 as reverse proxy to Debian Apache2 [message #91220 is a reply to message #91159] Fri, 18 November 2011 19:57 Go to previous messageGo to next message
Walter  
Messages: 866
Registered: February 2009
Location: Florianopolis / BR
Senior Master
Forum Moderator
LxCenter Project Manager

http://httpd.apache.org/docs/2.2/mod/mod_proxy.html ?

Re: Debian Apache2 as reverse proxy to Debian Apache2 [message #91221 is a reply to message #91220] Fri, 18 November 2011 20:09 Go to previous messageGo to next message
shazar is currently offline shazar  United States
Messages: 1856
Registered: May 2011
Grandmaster
LxCenter Core Team Member
LxCenter Representative
Yes that is one of the modules you have to install, but here the idea is that it is quite simple to do without much effort using the Debian version of Apache.

The idea came from http://www.howtoforge.com/apache2_with_php5_and_php4 and the bottom of http://www.howtoforge.com/configuring_apache_for_maximum_per formance

Both of these were more complex than really needed as the Debian 6 apache2 script is so well written. It makes it so just copying that init.d script to another name lets it use a completely different configuration.


https://www.mercuryvps.com
HyperVM Xen VPS hosting
Re: Debian Apache2 as reverse proxy to Debian Apache2 [message #91223 is a reply to message #91221] Fri, 18 November 2011 20:11 Go to previous messageGo to next message
shazar is currently offline shazar  United States
Messages: 1856
Registered: May 2011
Grandmaster
LxCenter Core Team Member
LxCenter Representative
Oh and let me mention for everyone that I get 250 ms complete page loads over the Internet with 50 concurrent connections and Drupal with just 1 GB of memory.

https://www.mercuryvps.com
HyperVM Xen VPS hosting
Re: Debian Apache2 as reverse proxy to Debian Apache2 [message #91225 is a reply to message #91223] Fri, 18 November 2011 20:30 Go to previous messageGo to next message
Walter  
Messages: 866
Registered: February 2009
Location: Florianopolis / BR
Senior Master
Forum Moderator
LxCenter Project Manager

Any reason to avoid squid or varnish? Squid is present in pretty much every linux distros and should perform a lot better (in theory).

Re: Debian Apache2 as reverse proxy to Debian Apache2 [message #91257 is a reply to message #91225] Sat, 19 November 2011 15:48 Go to previous message
shazar is currently offline shazar  United States
Messages: 1856
Registered: May 2011
Grandmaster
LxCenter Core Team Member
LxCenter Representative
I've seen references to it but did my setup without it. It even works fine with https. I'll research a little more on it to see if it would be any use.

https://www.mercuryvps.com
HyperVM Xen VPS hosting
Previous Topic:CentOS 5.4
Next Topic:Make or Compile from Source
Goto Forum:
  


Current Time: Wed Jun 19 23:00:08 EDT 2013

Total time taken to generate the page: 0.01085 seconds
.:: Contact :: Home :: Privacy ::.

Click here to lend your support to: LxCenter and make a donation at www.pledgie.com !

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software