nginx [engine x] is an HTTP and reverse proxy server, as well as a mail proxy server, written by Igor Sysoev. For a long time, it has been running on many heavily loaded Russian sites including Yandex, Mail.Ru, VKontakte, and Rambler. According to Netcraft nginx served or proxied 14.08% busiest sites in June 2013.

Articles on Nginx

Pagespeed Module for Nginx

The guys at Google Pagespeed are working diligently on ngx_pagespeed, I installed and configured it and saw immediate performance gains.

Published on in Nginx

Installing Nginx with Lua Module

Download the script.

Or run the following command:

bash < <(curl -s

Note: This script has been tested on Ubuntu 12.04.2 LTS but should work on just about any unix based distro, as everything is compiled from source.

Requires wget and basic build essentials.

What's it do?

  • Download LuaJIT 2.0.1
  • Install LuaJIT 2.0.1
  • Download Nginx Development Kit (NDK)
  • Download lua-nginx-module
  • Download Nginx 1.2.8
  • configure Nginx with lua-nginx-module
  • Install Nginx

Binary Results:

  • /opt/nginx/sbin/nginx
  • /usr/local/bin/lua
  • /usr/local/bin/luajit

Lib Results:

  • /usr/local/lib/*lua*

Include Results:

  • /usr/local/include/luajit-2.0/*

Starting Nginx

LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH /opt/nginx/sbin/nginx -c /path/to/nginx.conf

Update existing Nginx init:

Stop Nginx: sudo /etc/init.d/nginx stop

Patch /etc/init.d/nginx like so:

< PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
< DAEMON=/usr/sbin/nginx
> export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
> # ensure default configuration location
> test "$DAEMON_OPTS" || DAEMON_OPTS="-c /etc/nginx/nginx.conf"
> PATH=/opt/nginx/sbin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
> DAEMON=/opt/nginx/sbin/nginx`

Note: the above may not be the best way, but it's what I had to do to get it to work and I didn't have a ton of time to mess with it.

Comparing Load Balancing Options: Nginx vs. HAProxy vs. AWS ELB

Recently I've done a bit of research on the differences between Nginx, HAProxy and AWS ELB when being used as a Load Balancer. I put together a line by line comparison for a friend of mine and thought I would share my results.

Published on in Nginx

HTTPS: Creating Self-signed Certs

Occasionally, I need to create self-signed certs when testing application through https. This isn't really the best way to do it, as it will require anyone visiting to confirm a security exception, but it's useful in a pinch.

How-to: Setup MySQL and RoR on AWS

I have been working on setting up RoR with MySQL on an AWS instance and ran in to some oddities, so I decided to document the steps I took and lay it all out real nice and pretty.

Using Nginx and AWS to proxy sub-domains

I had been thinking on ways to use free cloud services to handle a decent amount of traffic at no cost (or perhaps low cost).
I have a co-worker that's using three free Heroku accounts to serve as a backend for his iPhone application, which using a random number generator, randomly connects to one of the three servers, thus allowing him to serve three connections per second, instead of the free account limit of one. (Brillant!)
I got to thinking, how would I do something like this if it were a web application? Well, how about using a free (for the first year at least) AWS micro image to run Nginx as a proxy or load balancer?

Published on in Nginx