Reverse proxy

I want to run nginx as reverse proxy for apache2 on my server but virtualmin always make my configurations to fail !

Steps :

1- Install nginx using it's official repo : http://nginx.org/en/download.html

2- Use this config file for nginx :

server {
    listen 80;
    server_name _;
    root /var/www;
    client_max_body_size 20M;
 
    location / {
        access_log      off;
        proxy_pass http://127.0.0.1:81;
        proxy_set_header X-Real-IP  $remote_addr;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_read_timeout 120;
        proxy_connect_timeout 120;
    }
}

3- Install rpaf_module for apache : http://stderr.net/apache/rpaf/download/

4- Add the following config file for rpaf config : /etc/httpd/conf.d/rpaf.conf

LoadModule rpaf_module        /usr/lib/httpd/modules/mod_rpaf-2.0.so
RPAFenable On
RPAFsethostname On
RPAFproxy_ips 127.0.0.1
RPAFheader X-Forwarded-For

5- Alter the following lines in apache config file : /etc/httpd/conf/httpd.conf :

Listen 127.0.0.1:81
NameVirtualHost 127.0.0.1:81

6- Change virtualmin configuration to use 127.0.0.1 and port 81 as default virtualserver config. /etc/webmin/virtual-server/config

web_port=81
dns_ip=
defip=127.0.0.1

The problem is just with step 6, virtualmin could understand that use 127.0.0.1 just for virtualserver IP, not for bind zone file !!

It also returns some error about non-matching IP addresses in Validate virtual-server section.

Please add this nice feature to virtualmin.

Status: 
Active

Comments

For step 6, you should instead change the IP to 127.0.0.1 at Server Configuration -> Change IP Address.

Are you sure you really want to run Nginx as a proxy in front of Apache though? Unless your site is very heavily loaded, this isn't going to speed it up .. especially if you are serving any kind of dynamic (PHP-generated) content.

Mostafa's picture
Submitted by Mostafa on Fri, 08/03/2012 - 14:04

I've just had a test on one of my dedicated servers running high loaded websites on apache 2.4.2, php-fpm 5.3.15 and nginx 1.2.2 as reverse proxy. without nginx as reverse proxy : load average ~ 3.0 with nginx as revererse proxy in front of apache : load average ~ 0.6

Please add official support for reverse proxy. It's awesome.