NGNIX (pronounced Engine X) is a web server /reverse proxy/load balancer used by many high traffic applications because it can handle thousands of simultaneous requests with its event-driven architecture.

It is faster than Apache and openLightSpeed in most areas

How does it work?

It instances a worker process for each CPU core that run concurrently and handle requests is a non-blocking fashion

How to configure it?

Next, we need to reconfigure our firewall software to allow access to Nginx, for this we use “Uncomplicated Firewall” (UFW)

We can list the applications configurations that ufw knows how to work with by typing:

  • Nginx Full: This profile opens both port 80 (normal, unencrypted web traffic) and port 443 (TLS/SSL encrypted traffic)
  • Nginx HTTP: This profile opens only port 80 (normal, unencrypted web traffic)
  • Nginx HTTPS: This profile opens only port 443 (TLS/SSL encrypted traffic)

To allow port 80 types the following command

You can verify the change by the following command

Check your Web Server

We can check with the systemd init system to make sure the service is running by typing

“systemctl” stands for system control and “systemd” which plays with the word System D “System D is a manner of responding to challenges that require one to have the ability to think quickly, to adapt, and to improvise when getting a job done”


The configuration is stored in

The areas that these brackets define are called “contexts”

A virtual server is defined by a server directive

The server configuration block usually includes a listen directive to specify the IP address and port on which the server listens for requests.

If a port is omitted, the standard port is used. Likewise, if an address is omitted, the server listens on all addresses.

NGINX tests the request’s Host header field against the server_name to find the appropriate server block for each request

If the Host header field does not match a server name, NGINX routes the request to the default server block which is the first one

NGINX Plus can send traffic to different proxies or serve different files based on the request URIs. These blocks are defined using the location directive placed within a server directive

A location context can contain directives that define how to resolve a request – either serve a static file or pass the request to a proxied server

You can use variables in the configuration file

A variable is denoted by the (dollar) sign at the beginning of its name.

With the error_page directive, you can configure NGINX Plus to return a custom page along with an error code

listen 80 - The server block will listen for incoming connections on port 80 for the specified domain.

There is one more place where the configuration is stored

If you want to upload large files to the server you ill have to update the above file with the following code

Redirect Domains

Restart NGINX

We can also do A/B testing with nginx with split_clients context


Written by

Finding Magic.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store