Ngnix - High Performance Web Server, Proxy Server, Content Cache and Reverse Proxy

  •        0

We aggregate and tag open source projects. We have collections of more than one million projects. Check out the projects section.

Nginx is a High Performance Web Server, Proxy Server, Content Cache and Reverse Proxy server. It can also be used as mail proxy server and a generic TCP/UDP proxy server. Nginx claims to be more efficient and faster in the Web space compared to the other web servers. This can be evident with the architecture which is based on asynchronous event-driven approach. The event driven architecture enables to scale to hundreds / thousands of concurrent connections.

How it works:

Nginx webserver has the following components.

  1. Master process – Reads configuration, bind to ports and create child processes
  2. Cache Loader process – Runs at startup / scheduled conservatively to load disk-based cache
  3. Cache Manager process – Runs periodically and prunes entries from disk caches to manage
  4. Worker process – Handles network connections, reads and writes content to disk and communicate with upstream server

Each worker process is provided with a set of listen sockets by the master process. The worker process begin by waiting for events on the listen sockets. Events are initiated by new incoming connections which are assigned to a state machine.

Why Ngnix is faster:

Typically Linux applications are built as process or threads which working in “blocking” mode. However with Nginx, the worker process handles this in non blocking mode as described below:

Events occur on sockets and worker process handles them

  1. An event on the listen socket means that a client has initiated a new connection reques
  2. An event on the connection socket means that a client has made a HTTP request.

Each new connection creates another file descriptor and consumes a small amount of memory in the worker process. These processes can be pinned to process CPUs and hence context switches are very minimal.

Ngnix as Load Balancer:

In a cloud environment usually there will be one or more web servers to serve the user request. Ngnix will be placed in front of all web servers and it will balance the incoming request to the available web servers. It supports session persistence (sticky session) where in the request from same client / IP will be routed to same backend server. Web server maintains session, from login to logout all request from that client will be routed to the same backend server.

Ngnix as Proxy server and Content Cache Server

In production environment the actual web servers will not be exposed to public. There will be a proxy server or CDN will be placed in-front of the web servers. Client will hit the proxy server which in turn proxies to the backend server. Static content like images, CSS, Javascript etc may not change frequently. Ngnix can cache the static content so that the request will be directly served from cache and it does not need to hit the backend server.

Installing Ngnix:

On Debian / Ubuntu:      

sudo apt-get install nginx


On Redhat / Centos:       

sudo yum install nginx


Start / Stop / Restart Service:

sudo service nginx {start | stop | restart | reload }


To view the status:

sudo service status nginx


Simple Configuration:

Ngnix conf file will be located at /etc/nginx/nginx.conf. If it does not exist there, it may also be at /usr/local/nginx/conf/nginx.conf or /usr/local/etc/nginx/nginx.conf. Below example has a simple configuration where nginx shows the capability of Reverse proxy and also a load balancer.


user       www www;  ## Default: nobody

worker_processes  5;  ## Default: 1

error_log  logs/error.log;

pid        logs/;

worker_rlimit_nofile 8192;


events {

  worker_connections  4096;  ## Default: 1024



http {

  include    conf/mime.types;

  include    /etc/nginx/proxy.conf;

  include    /etc/nginx/fastcgi.conf;

  index    index.html index.htm index.php;


  default_type application/octet-stream;

  log_format   main '$remote_addr - $remote_user [$time_local]  $status '

    '"$request" $body_bytes_sent "$http_referer" '

    '"$http_user_agent" "$http_x_forwarded_for"';

  access_log   logs/access.log  main;

  sendfile     on;

  tcp_nopush   on;

  server_names_hash_bucket_size 128; # this seems to be required for some vhosts


  server { # simple reverse-proxy

    listen       80;


    access_log   logs/domain2.access.log  main;


    # serve static files

    location ~ ^/(images|javascript|js|css|flash|media|static)/  {

      root    /var/www/virtual/;

      expires 30d;



    # pass requests for dynamic content to rails/turbogears/zope, et al

    location / {





  upstream big_server_com {

    server weight=5;

    server weight=5;





  server { # simple load balancing

    listen          80;


    access_log      logs/big.server.access.log main;


    location / {

      proxy_pass      http://big_server_com;





Updating Configuration:

Updating configuration is simple, lightweight and a reliable operation with Zero downtime of application. Whenever there is a new config available and when master process receives a signal to reload the config, the following sequence takes place.

  1. Reloads configuration and forks new worker processes. These new worker processes begin accepting connections and process traffic
  2. Signals old worker processes to gracefully exit. As soon as HTTP request is complete, the worker process shuts down the connection, and when all connections are closed, worker process exits.





We publish blog post about open source products. If you are interested in sharing knowledge about open source products, please visit write for us

Subscribe to our newsletter.

We will send mail once in a week about latest updates on open source tools and technologies. subscribe our newsletter

Related Articles

An introduction to web cache proxy server - nuster

  • web-cache proxy-server load-balancer

Nuster is a simple yet powerful web caching proxy server based on HAProxy. It is 100% compatible with HAProxy, and takes full advantage of the ACL functionality of HAProxy to provide fine-grained caching policy based on the content of request, response or server status. This article gives an overview of nuster - web cache proxy server, its installation and few examples of how to use it.

Read More

Getting Started on Undertow Server

  • java web-server undertow rest

Undertow is a high performing web server which can be used for both blocking and non-blocking tasks. It is extermely flexible as application can assemble the parts in whatever way it would make sense. It also supports Servlet 4.0, JSR-356 compliant web socket implementation. Undertow is licensed under Apache License, Version 2.0.

Read More – The First Multithreaded Application Server for PHP written in PHP

  • appserver application-server php

What if you could reliably run PHP without Nginx or Apache, but also without relying on its internal server? What if you could do async operations in PHP with true multi threading, fully taking advantage of multi core processors without hacks or a jungle of callbacks? What if you had drag and drop installation support for your PHAR packaged web apps in an environment identical to its production counterpart? Welcome to – the worlds first open source application server for PHP.

Read More

Univention Corporate Server - An open source identity management system

  • ucs identity-management-system

Univention Corporate Server is an open source identity management system, an IT infrastructure and device management solution and an extensible platform with a store-like App Center that includes tested third party applications and further UCS components: This is what Univention combines in their main product Univention Corporate Server, a Debian GNU/Linux based enterprise distribution. This article provides you the overview of Univention Corporate Server, its feature and installation.

Read More

Lucene Vs Solr

  • searchengine lucene solr

Lucene is a search library built in Java. Solr is a web application built on top of Lucene. Certainly Solr = Lucene + Added features. Often there would a question, when to choose Solr and when to choose Lucene.

Read More

Build Consulting Website using Next.js

  • react nextjs website-development ssr

One of the popular web framework for building Single page application (SPA) or static site is React library. Application built with React packages will be rendered completely on the client side browser. If you want to reduce the load on client side browser, we need to pre-render the pages in server (Serer side rendering) and serve it to the client. So the client loads the page like simple html page. Also if the pages are rendered from server then search engine will be able to fetch and extract the pages. To do SSR for React, the best abstraction framework is Next.js. In this blog, we will explain how to build a simple consulting website using NextJS.

Read More

Introduction to Apache Cassandra

  • cassandra database nosql

Apache Cassandra was designed by Facebook and was open-sourced in July 2008. It is regarded as perfect choice when the users demand scalability and high availability without any impact towards performance. Apache Cassandra is highly scalable, high-performance distributed database designed to handle large voluminous amounts of data across many commodity servers with no failure.

Read More

Desktop Apps using Electron JS with centralized data control

  • electronjs couchdb pouchdb desktop-app

When there is a requirement for having local storage for the desktop application context and data needs to be synchronized to central database, we can think of Electron with PouchDB having CouchDB stack. Electron can be used for cross-platform desktop apps with pouch db as local storage. It can sync those data to centralized database CouchDB seamlessly so any point desktop apps can recover or persist the data. In this article, we will go through of creation of desktop apps with ElectronJS, PouchDB and show the sync happens seamlessly with remote CouchDB.

Read More

Getting Started With Django Python Web Framework

  • django python web-framework

Django is a high-level Python Web framework that encourages rapid development and clean, pragmatic design. It is pre-loaded with user authentication, content administration, site maps, RSS feeds and many more tasks. Security features provided are cross site scripting (XSS) protection, cross site request forgery protection, SQL injection protection, click-jacking protection, host header validation, session security and so on. It also provides in built caching framework.

Read More

Angular Service Workers Usage Guide

  • angular service-worker offline-app

Web developers come across scenarios like web application completely breaks when workstation goes offline. Likewise to get into our application, every time we need to open a browser and then access it. Instead if it is in app, it will be easy to access for end-user. Push notifications similar to email client need to be done through web application. All these are addressed by a magic called service worker.

Read More

Data Fetching and Form Building using NextJS

  • nextjs data-fetching form-handling

Next.js is one of the easy-to-learn frameworks for server-side pre-render pages for client-side web applications. In this blog, we will see how we can fetch data from API and make it pre-render pages. Also, let's see how forms work in Next.js and collect the data without maintaining the database.

Read More

SeoToaster: easy, fast and efficient open source CMS for top SEO performance

  • cms content-management-system seo ecommerce

SeoToaster is a free Open Source CMS & Ecommerce solution to build, manage and market websites optimized for for top search engine performance. As the name implies, Seo Toaster is to date the only content management system (CMS) to truly integrate SEO execution and web marketing automation technology in full compliance with the search engines industry’s best practices.

Read More

Introduction to Light 4J Microservices Framework

  • light4j microservice java programming framework

Light 4j is fast, lightweight, secure and cloud native microservices platform written in Java 8. It is based on pure HTTP server without Java EE platform. It is hosted by server UnderTow. Light-4j and related frameworks are released under the Apache 2.0 license.

Read More

Scale up vs Scale out. First decision to make before moving to cloud

  • cloud scale-up scale-out scalability

Before moving to cloud, First decision to make is whether Scale up the hardware or Scale out with multiple systems. Both has its pros and cons.

Read More

WebSocket implementation with Spring Boot

  • websocket web-sockets spring-boot java

Spring Boot is a microservice-based Java framework used to create web application. WebSocket API is an advanced technology that provides full-duplex communication channels over a single TCP connection. This article explains about how to implement WebSocket using Spring Boot.

Read More

Light4j Cookbook - Rest API, CORS and RDBMS

  • light4j sql cors rest-api

Light 4j is a fast, lightweight and cloud-native microservices framework. In this article, we will see what and how hybrid framework works and integrate with RDMS databases like MySQL, also built in option of CORS handler for in-flight request.

Read More

Understanding Web Real-Time Communication (WebRTC)

  • webrtc communication web

Web Real-Time Communication (WebRTC) is an open source project currently being developed with an aim to provide real time, peer-to-peer communication between web applications. WebRTC provides simple JavaScript APIs that help developers to easily build web applications with real time audio, video and data transfer capabilities. This blog has been written assuming that the reader has zero knowledge of how WebRTC works and hence have explained the entire working in detail using simple terms and analogies wherever possible. Let’s get started!

Read More

LogicalDOC - Open Source DMS

  • dms document-management-system

LogicalDOC is both a document management and a collaboration system. The software is loaded with many functions and allows organizing, indexing, retrieving, controlling and distributing important business documents securely and safely for any organization and individual.

Read More

Push Notifications using Angular

  • angular push-notifications notifications

Notifications is a message pushed to user's device passively. Browser supports notifications and push API that allows to send message asynchronously to the user. Messages are sent with the help of service workers, it runs as background tasks to receive and relay the messages to the desktop if the application is not opened. It uses web push protocol to register the server and send message to the application. Once user opt-in for the updates, it is effective way of re-engaging users with customized content.

Read More

ONLYOFFICE Document Server, an online office app for Nextcloud and ownCloud

  • office office-suite word spreadsheet

ONLYOFFICE Document Server is a free collaborative online office suite including viewers and editors for texts, spreadsheets and presentations, fully compatible with Office Open XML formats (.docx, .xlsx, .pptx). This article provides you the overview of ONLYOFFICE Document Server, its features, installation and integration with Nextcloud and ownCloud.

Read More

We have large collection of open source products. Follow the tags from Tag Cloud >>

Open source products are scattered around the web. Please provide information about the open source projects you own / you use. Add Projects.