NGINX is a popular, free, and open-source web server.

The default NGINX configurations are good enough to get the web server working.

You will find the configuration files in the/etc/nginxdirectory on a Linux machine.

An illustration showing two web servers deployed in a network

What Is NGINX?

Another advantage of using NGINX is that it is easy to configure and learn.

Lets see how to do it.

nginx.configuration file showing 4 processors configured

Configure Worker Processes in NGINX

NGINX architecture consists of one master process and several worker processes.

The job of the master process is to assess the configuration and manage workers.

The process value is set toautoby default.

commented gzip configuration in nginx configuration file

This sets the number of worker processes equal to the number of available CPU cores.

Configure Worker Connections

Another parameter that you could modify to enhance NGINX’s performance is worker connections.

This is the maximum number of TCP connections that each worker process can simultaneously handle.

Most systems have a default value of 512 connections, but many modern systems also support a bigger number.

you’re free to then modify theworker_connectionsvariable in the NGINX configuration file to improve performance.

Allow GZIP Compression in NGINX

NGINX uses GZIP for file compression and decompression.

To allow GZIP compression, add the following lines in the NGINX configuration file:

4.

Limit Timeout Value in NGINX

Reduced timeout values also play a major role in enhancing NGINX performance.

Thekeepaliveconnections reduce the processor and web link overhead when opening and closing connections.

you could modify the following parameters in the configuration file to limit timeouts:

5.

Adjust Buffer Size

you’re able to also adjust NGINX buffers to optimize the server performance.

you oughta set the following buffer parameters for NGINX to function at its best:

6. it’s possible for you to disable access logs which will save some disk space and CPU processing.

Completely disabling logs is not a good practice.

In this case, it’s possible for you to enable access logs buffering.

Add the following line in the NGINX config file to allow access logs buffering:

7.

Caching of this content allows it to be placed in locations that are easily accessible.

This mechanism reduces bandwidth usage, allows fast accessibility, and subsequently improves the websites performance.

When a client requests static content, the server will serve a cached version of the content.

This directive allows the file descriptor and frequently visited files to be cached to the server.

If it works, move to the next setting.

If not, you’ve got the option to always change the configuration back to the default value.