Personal tools
You are here: Home Web Reverse Proxy And Cache Install NGINX

Install NGINX

The Centos v5.1 VM is violet.lucidsolutions.co.nz (192.168.0.60).

Installation

I couldn't easily find a nginx RPM for CentOS 5 (or RHEL), but I didn't look that hard (Update: nginx is now in EPEL).  Just use the x86_64 version from Fedora 8 updates. wget the rpm from the fedora 8 updates.
# rpm --import http://download.fedora.redhat.com/pub/fedora/linux/releases/8/Fedora/x86_64/os/RPM-GPG-KEY-fedora
# yum localinstall nginx-0.5.35-1.fc8.x86_64.rpm

Configuration

Configure the nginx service in /etc/nginx/nginx.conf. Start with a vanilla proxy, without any caching (where the proxy_pass host is direct to Zope), and then change it to go via a local Varnish cache  [2]. It is necessary to use the virtual host monster with Zope (which is why the proxy_pass line has all the 'stuff').

It is important to allow nginx (or Varnish) out to access the plone server. Add an iptables rule to /etc/sysconfig/iptables:

-A tcpOut  -p tcp -m tcp --dport 8080 --destination plone-internal.lucidsolutions.co.nz -m state --state NEW -j ACCEPT

I found that when adding large documents into plone the post would fail. This requires a client_max_body_size directive.

Run

Enable and start the service
# chkconfig nginx on
# service nginx start
 

Links

Plone related

Appendices

[1] NGINX install

 
 
Dependencies Resolved
=============================================================================
 Package                 Arch       Version          Repository        Size
=============================================================================
Installing:
 nginx                   x86_64     0.5.35-1.fc8     nginx-0.5.35-1.fc8.x86_64.rpm  674 k
Installing for dependencies:
 perl                    x86_64     4:5.8.8-10.el5_0.2  updates            12 M
Transaction Summary
=============================================================================
Install      2 Package(s)
Update       0 Package(s)
Remove       0 
Package(s)
Total download size: 13 M
Is this ok 
[y/N]: y
Downloading Packages:
Running Transaction Test
Finished 
Transaction Test
Transaction Test Succeeded
Running Transaction
  
Installing: perl                         ######################### [1/2]  
Installing: nginx                        ######################### [2/2]

Installed: nginx.x86_64 0:0.5.35-1.fc8
Dependency Installed: perl.x86_64 4:5.8.8-10.el5_0.2
Complete!

[2] NGINX configuration for plone, a dump file based web site, and a default file based site.

user  nginx;
worker_processes  1;

error_log   /var/log/nginx/error.log;

pid        /var/run/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] $request '
                      '"$status" $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    gzip  on;

    client_max_body_size 10M;

    #
    # Plone
    #
    server {
        listen       80;
        server_name  plone.lucidsolutions.co.nz;

        access_log  /var/log/nginx/plone.access.log  main;

        location / {
            # proxy_pass http://plone-internal.lucidsolutions.co.nz:8080/VirtualHostBase/http/plone.lucidsolutions.co.nz:80/plone/VirtualHostRoot/;
            proxy_pass http://localhost:6081/VirtualHostBase/http/plone.lucidsolutions.co.nz:80/plone/VirtualHostRoot/;
            proxy_set_header        Host            $host;
            proxy_set_header        X-Real-IP       $remote_addr;
            proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
        }
    }

    #
    # Business card style main web site
    #
    server {
        listen       80;
        server_name  www.lucidsolutions.co.nz lucidsolutions.co.nz;

        access_log  /var/log/nginx/www.access.log  main;

        location / {
            root /var/www/html/www;
            index index.html;
        }
    }

    #
    # Default
    #
    server {
        listen       80;
        server_name  _ *;

        access_log  /var/log/nginx/default.access.log  main;

        location / {
            root /var/www/html/default;
            index index.html;
        }
    }
}

Document Actions