If your web site performance is struggling, using Nginx could be a solution for you. Unlike some web servers, Nginx is not a drop in replacement for Apache, but integrating this alternate web server into your operations can be a powerful solution to your web performance issues. This is just a general overview of three basic deployment methods we use when try to address web performance issues. Whether you use Nginx as a proxy server or for directly serving traffic, proper integration can boost web site performance significantly.

About Nginx

Nginx is a web server that promises to have the highest performance, lowest memory footprint of any web server available today. According to Netcraft, it is the 3rd most popular web server in use today with about an 11% share of the market. Nginx’s popularity has quickly risen thanks to ease of configuration, high performance and scalability. In our use, Nginx works well when used as a proxy server or for serving static content.

Netcraft web server survey

Earlier this year, Nginx grew up from its open source community-supported roots with a new commercial support option. It is one of the best supported open source web servers available, The commerical support came on the heels of a $3 million series A funding round. Some of the biggest names on the web, such as Facebook, Groupon, Zynga, and Sourceforge, use Nginx web servers in their operations. So there is some real firepower behind Nginx with both commercial support and a who’s who of community contributors.

Should I Use Nginx?

Before adopting any new component into your web operations, you need to ask, “Do I really need to introduce this new software or can simple changes to existing tools work?” Too often, I find overly complicated hosting deployments where multiple web servers are mixed together like head cheese. The result is not appetizing (sorry head cheese fans).
In most cases, simple tweaks to the existing tools would have worked as well or better. rackAID routinely simplifies deployment as we move people to new web hosts. By simplifying the infrastructure, we typically see improved performance, better resource utilization and faster recovery of service outages.

3 Ways To Deploy Nginx

If you have decided to use Nginx, there are three basic models for deployment:

  • Web Server
  • Proxy Server
  • Hybrid Deployments

Nginx as Web Server

This one is pretty simple. Like Apache, Nginx can perform as a web server. We primarily use Nginx to serve static content such as images, flash, JavaScript and CSS files, but you can also run Ruby on Rails, PHP or other scripting languages.
In our experience, Nginx is an excellent and easy replacement for Apache when serving static content. We have clients serving millions of files per month with Nginx running on entry level cloud systems.
Nginx as Web Server


  • Simple Setup
  • Excellent for Static Content
  • Low memory requirements


  • Have to Learn New Configuration Syntax
  • Smaller Support Community than Apache

Nginx as a Proxy

Nginx can be used a proxy server — a reverse proxy to be more technical. When used as a proxy server, Nginx accepts the initial connection and then passes the traffic to a backend server. The backend server is often using Apache, but you can proxy to any web server you wish.
When used as a proxy, Nginx can load balance and segment traffic based on URL, IP or other metrics. It can also be used to rate limit requests, filter out bad bots, and serve as a rudimentary web application firewall. We have used Nginx successfully in this role to block application level DDoS attacks.
Nginx as Proxy Server


  • Load balancing
  • Traffic filtering


  • Potentially added costs
  • More complex web infrastructure

Hybrid Nginx Deployments

In hybrid deployments, Nginx functions both as a web server and as a proxy server. We typically serve static files directly from Nginx and have it proxy the remaining traffic to a backend Apache server. Thanks to its flexibility, this is easy to do. In this model, you configure Nginx both as a proxy and web server. You use the filtering capabilities to route traffic to the appropriate destination.
If you break down a web page, you often will find more than 90% of HTTP requests are for static content. By serving the static content directly from Nginx, you can reduce the number of requests sent to your web servers significantly. This approach is often less costly than trying to load balance multiple Apache servers.
Nginx in Hybrid Web/Proxy Server Model


  • Offload static content
  • Better overall web performance


  • Potentially added costs
  • More complex web infrastructure
  • Have to manage static files on Nginx server (or use NFS)

Do you use Nginx?

There are other scenarios for sure, but these are the 3 basic ways you can deploy Nginx within your web operations. If I missed one, let me know.