Personal tools
You are here: Home Plone XP Open Source Software Review How Nginx can make your Web application fast?

How Nginx can make your Web application fast?

— filed under: ,

Nginx is considered as a better Web server than Apache HTTPD server.  How can it help your Web application?

Why Nginx


Installation Memo

First of all, there are some dependence for Nginx:

  • Nginx rewrite module requires PCRE library, Perl Compatible Regular Expressions:
  • Nginx ssl module depends on a SSL tookit, the popular one is OpenSSL.  Make sure that the OpenSSL version is 0.9.8e or higher.

Basic commands:

$ sbin/nginx # start nginx server: both master processor and worker processor
$ sbin/nginx -h # help message, simple and easy to use

Basic Configuration

Nginx's main documentation wiki site:

rewrite condition and rewrite rule

Variables that we could use:

$host, $http_port

The core module defines many useful variables:

Timeout Settings

We have the following directive for timeout setting:


Advance Rewrite Rules

some advanced Nginx rewrite rules:

User-Based (mod_userdir) Website Directories with Nginx:

Nginx, public_html, Part2 - PHP script:

Rewrite rules for wordpress:

It is a bit headache for first time Nginx user try to migrate some Apache HTTPD rewrite rules to Nginx rewrite rules.  Here are some start up blog might help:

Migrate from Apache to Nginx:

Nginx Doc Convert Rewrite Rules:

SSL Support

The module httpd_ssl_module needs to be enabled for SSL support on Nginx.

ssl support on Nginx is quiet easy and strait forward:

If you are using SSL and FastCGI together, you better turn on the HTTPS param for factcgi.  I have experienced a redirect loop issue related to it.  Check this for more details:

fastcgi_param HTTPS on;

Gzip Support in Nginx

Gzip compression is supported by default in Nginx. However Nginx is a newer enough Web server that some of the older browser may not happy about gzip compression.  Check this out:

So the gzip_disable option is used to disable gzip for some browser.  The very useful one is to disable gzip for IE 6:

gzip_disable .MSIE [1-6].(?!.*SV1).;

Without this option, IE version 6 could not load some Nginx powered Web sites.  It will hang up until you reloaded the page!

You also could trace how Nginx using gzip:  It is using the strace.

Default Error Page

The error_page directive is used to set up default error (404, 500, etc) pages.

Document Actions