Varnish in front of Apache, Apache on another port

sneakerpeet

Verified User
Joined
Oct 25, 2009
Messages
5
Location
Amsterdam
I'm planning to relieve some static-file and media-file stress from Apache and put Varnish into action as a cache in front of Apache.

Now I am looking for ways to keep using DirectAdmin for the Apache configuration, but have all the sites run on 127.0.0.1 and port 8000 (or some other arbitrary port). This way Varnish takes the heat on port 80 of the sites and reroutes the 'smart' calls to Apache, and all the mediafiles come out of it's cache.

I did notice the warnings in the domain-config files to not touch them, because DirectAdmin will overwrite them. How should one pull this off?

Anyone got an idea?
 
Varnish should make apache faster...

And take of the load. Anyone done this? I am trying now...
But varnish show my default apache page...
 
I think you will need to change port 80 to another one in these files:
nano /etc/httpd/conf/httpd.conf
nano /etc/httpd/conf/ips.conf

And next change all your current websites config file, example:
nano /usr/local/directadmin/data/users/site1acc/httpd.conf
nano /usr/local/directadmin/data/users/site2acc/httpd.conf
nano /usr/local/directadmin/data/users/siteabc/httpd.conf

I got the warning with Virtual Host but it still works good.

You can check this one too: http://www.directadmin.com/forum/showthread.php?t=40044&p=208163#post208163


I faced another issue and still stop using it, that's I can't configure it to allow cookie login :(
 
Try nginx instead, it's very easy to integrate as frontend when Apache+PHP used as backend. Apache is listening on localhost:80 and accept local connection while nginx serving incoming HTTP requests on external IP port 80.

If you need nginx config, ask me and I give you my production environment config (serving over 1500 virtual hosts).

Also, you need to put your modified virtual_host_* templates into directadmin/data/templates/custom/, virtual_host.conf + virtual_host_sub.conf for Apache 1.3.x and virtual_host2.conf + virtual_host2_sub.conf. Do not forget to edit redirect_virtual_host.conf as follows

Code:
<VirtualHost 127.0.0.1:80>
        ServerName |POINTER|
        ServerAlias www.|POINTER|
        Redirect / http://www.|DOMAIN|/

For example, my virtual_host_2.conf looks like this:

Code:
|?DOCROOT=`HOME`/domains/`DOMAIN`/public_html|
|?OPEN_BASEDIR_PATH=`HOME`/:/tmp:/usr/local/lib/php/|
<VirtualHost 127.0.0.1:80>
|CUSTOM|
|?CGI=ScriptAlias /cgi-bin/ `DOCROOT`/cgi-bin/|
        ServerName www.|DOMAIN|
        ServerAlias www.|DOMAIN| |DOMAIN| |SERVER_ALIASES|
        ServerAdmin |ADMIN|
        DocumentRoot |DOCROOT|

When you modified your templates and httpd.conf to listen to localhost:80, you need to rewrite all users virtual hosts with new templates, do

# echo "action=rewrite&value=httpd" >> /usr/local/directadmin/data/task.queue
# /usr/local/directadmin/dataskq d800

and wait for about a minute. Well done.
 
Yes, thanks for your guide.
I'm trying to install nginx in my localhost before use it in my vps server.

Thanks.
 
I am testing Danginx plugin right now, its ease of install was reason I went plugin, does your config files work in situation like that?
 
as far as I can tell the danginx plugin is just an auto installer (for $5 a month) with no config abilities from the admin panel so I most likely will be trying what you posted in a bit.
I just need to verify some htaccess rewrite code and change to nginx and see if I can make the h264_nginx module compile right and work..
is the code posted what you are using as production config?
 
Back
Top