Personal tools
You are here: Home Web Reverse Proxy And Cache Rebuilding a Nginx reverse proxy with CentOS 6.x
 

Rebuilding a Nginx reverse proxy with CentOS 6.x

These are the simple steps to rebuild a CentOS 5 machine with CentOS 6 that acts as a simple reverse proxy with cache. The main motivation is to workaround an issue with Xen where the network receive path was failing (and making this web site very unreliable). The secondary issue is to have a 'standard' Nginx build that supports TLS SNI.

Base machine:

  • CentOS 6.2
  • 512MB RAM
  • 2 cores
  • 8GB root filesystem disk
  • 1GB swap disk
  • single IPv4 and IPv6 address
  • chrony synchronised time

 

Steps

  1. Install repositories
  2. Install packages
  3. Restore configuration from subversion
  4. Verify and start services
  5. Test

Install Repositories

Use the Nginx repository for Nginx, and the EPEL repository for Varnish.

# rpm -Uvh http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm
# rpm -Uvh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-7.noarch.rpm

Install Packages

Install varnish from EPEL and Nginx from the main Nginx repositories is very straight forward:

# yum install nginx varnish

Restore Configuration

The configuration for Nginx and Varnish is backed up and versioned in subversion.  Checkout the configuration file from the local repository:

# yum install subversion

Checkout the entire machine configuration from subversion. This includes:

  • static http content in /var/www/html
  • nginx configuration in /etc/nginx
  • varnish configuration in /etc/varnish & /etc/sysconfig/varnish
# svn --force co  https://svn.lucidsolutions.co.nz/svn/config/trunk/w3/violet /

Start

Test the nginx configuration

# nginx -t

Test the varnish configuration

$ varnishd -C -f /etc/varnish/default.vcl

Start the services

# chkconfig varnish on
# chkconfig varnishlog on

# service nginx start
# service varnishlog start
# service varnish start

Test

Use https://www.ssllabs.com/ssltest/ to test/verify the SSL setup.

Links

Appendices

Howto Test Varnish vcl

varnishd -C -f /etc/varnish/default.vcl

Install

# yum install nginx varnish
Dependencies Resolved

========================================================================================
 Package               Arch          Version                       Repository      Size
========================================================================================
Installing:
 nginx                 x86_64        1.2.1-1.el6.ngx               nginx          331 k
 varnish               x86_64        2.1.5-1.el6                   epel           263 k
Installing for dependencies:
 cloog-ppl             x86_64        0.15.7-1.2.el6                base            93 k
 cpp                   x86_64        4.4.6-3.el6                   base           3.7 M
 expect                x86_64        5.44.1.15-2.el6               base           256 k
 gcc                   x86_64        4.4.6-3.el6                   base            10 M
 glibc-devel           x86_64        2.12-1.47.el6_2.12            updates        967 k
 glibc-headers         x86_64        2.12-1.47.el6_2.12            updates        598 k
 jemalloc              x86_64        3.0.0-2.el6                   epel            82 k
 kernel-headers        x86_64        2.6.32-220.23.1.el6           updates        1.6 M
 libgomp               x86_64        4.4.6-3.el6                   base           115 k
 mpfr                  x86_64        2.4.1-6.el6                   base           157 k
 ppl                   x86_64        0.10.2-11.el6                 base           1.3 M
 tcl                   x86_64        1:8.5.7-6.el6                 base           1.9 M
 varnish-libs          x86_64        2.1.5-1.el6                   epel            89 k

Transaction Summary
========================================================================================
Install      15 Package(s)

Total download size: 21 M
Installed size: 45 M
Document Actions