+32 3 450 88 42

Automation Thursday

How to use Nginx in software testing

Posted by: Eva
Category: Business, Test automation

You might wonder, what is the connection between Nginx and software quality? Or maybe you think, what is this Nginx thing exactly? Without realizing it, you have probably already used this tool, or at least, the implementation of it.

An introduction

Nginx is a web server that originated in 2002 as an attempt to solve the so-called C10k problem where it aspires to achieve efficient scheduling of connections. This stands for concurrently handling (more than) ten thousand connections (not the same as handling many requests per second). In this regard, it was initially written with the explicit goal of outperforming Apache web server. It can be used on Windows or Linux servers. However, it is considered less stable on Windows and only to be used for development and testing purposes (as opposed to Apache which has equal support for both platforms).


The different faces of Nginx

Apart from being a web server, Nginx has many faces. Mostly it is used as a reverse proxy allowing for resources, originating from one or more different servers, to be served to a client as if they were all coming from the proxy. And this is one of the features where we can see a clear connection with testing and test automation.

In some use cases it is used to serve multiple API’s or microservices to a user, allowing for the creation of test and staging environments. In combination with Docker and Kubernetes, this can be a powerful tool to streamline deployment of these environments to facilitate the testing process. Performance testing can also benefit from this, thanks to the load-balancing functionality of Nginx.

When it comes to security it also offers the possibility of SSL termination/offloading. Where a request on a secured connection can either be re-encrypted from a public certificate to an internal privately secured endpoint or simply directed to a trusted internal service on the network without additional encryption.

Nginx SSL termination/offloading

It’s (almost) for free!

Till today the tool remains free and open-source. But if necessary there are also commercial licenses available, such as NGINX Plus, with additional functionality. These products are provided by NGINX Inc. founded by the Russian software engineer Igor Sysoev.

The commercial license NGINX Plus is built on top of the open-source version and provides some exclusive enterprise-grade features such as: health checks, monitoring, security controls and many more. Additionally configuration can be done through NGINX Plus’s built-in API which allows for automation of common tasks and workflows.

Nginx controller

A guide to automation

There are several methods to approach this automation. First of all, the tool can be used to push new application versions to production or any DTAP environment at any stage of the application lifecycle. When using the NGINX Plus API this process can be simplified by avoiding manually update configuration files.

A second method is automated service discovery. Modern microservices-based applications can have a myriad of services that are being deployed regularly. Manual updating of the configurations for all these services can be a time-consuming process. Service discovery facilitates this by automatically updating these service instances.

Thirdly Nginx can be used for orchestration and management for example to centralize configuration of multiple Nginx instances that are running alongside each other for load-balancing application traffic. In combination with Jenkins it can be very powerful in assisting DevOps to streamline CI/CD pipelines, to trigger a Jenkins build from a versioning platform (Github, Azure Devops, …). Which on its turn can ensure that the new deployments are running on fresh Nginx instances with a clean cache and the latest code.

Web server developers: market share of all sites


In short, Nginx is becoming an indispensable tool in software development and quality assurance. Over the years it has made it’s way to the top of most widely used web servers leaving Apache, Microsoft and Google behind. In NetCraft’s February 2020 Web Server Survey it leads the ranks at 36% of market share out of more than one billion surveyed sites, with Apache running up at 24%. Chances are increasingly big you come across websites and applications being served by the tool, with clients like Adobe, Wikipedia, WordPress, Zendesk, ING, Discovery, Canal+, and many more.

Written by Bart Taelemans.

Used sources: | | | |

Interested in this tool or some questions about it? Contact us via the contact button, we’ll get back to you within 24 hours! ➡