What is Nginx and how to use it - Web server, reverse proxy, and (not really) application server

  

Nginx (pronounced “engine-x”) is one of the most widely used software in the world for web traffic management. Created in 2004 to solve scalability problems, it is now the basis of many high-traffic sites such as Netflix, GitHub, and Cloudflare.

https://nginx.org/

In this article we will see:

  • what is Nginx
  • what is it for and how is it used
  • whether it can be considered an application server or just a web server, and why
🔗 Do you like Techelopment? Check out the site for all the details!

What is Nginx

Nginx is primarily a web server and reverse proxy, designed to handle a very large number of concurrent connections with very low resource consumption.

Unlike more traditional web servers (like Apache in its classic model), Nginx uses an event-driven and non-blocking architecture, making it extremely efficient in high-traffic scenarios.

In summary, Nginx can perform several roles:

  • Web server for static content
  • Reverse proxy
  • Load balancer
  • HTTP cache
  • SSL/TLS termination

What is Nginx used for?

1. Web server for static content

Nginx is excellent at serving static files such as:

  • HTML
  • CSS
  • JavaScript
  • images and videos

Thanks to its architecture, it can serve thousands of concurrent requests with very low latency.

2. Reverse proxy

One of the most common uses of Nginx is as a reverse proxy in front of one or more application servers (e.g., Node.js, Java Spring, PHP-FPM, Python Django).

In this scenario:

  • Nginx receives HTTP requests
  • forwards them to the appropriate backend
  • returns the response to the client

This allows you to:

  • hide internal infrastructure
  • improve security and performance
  • easily manage multiple applications behind the same domain

3. Load Balancer

Nginx can distribute traffic across multiple backends using different strategies:

  • round-robin
  • least connections
  • hashing

This is a widely used solution for increasing application availability and scalability.

4. SSL/TLS Termination

Nginx can handle HTTPS encryption:

  • SSL/TLS certificates
  • Automatic renewal (e.g., with Let's Encrypt)

This allows backends to communicate in plain HTTP, reducingcomplexity and load.


How to use Nginx

Installation on Linux

On Linux systems, it is available in the official repositories:

sudo apt install nginx

Basic configuration

The main configuration file is:

/etc/nginx/nginx.conf

Site configurations are often located in:

/etc/nginx/sites-available/
/etc/nginx/sites-enabled/

Simple server block example

server { 
  listen 80; 
  server_name example.com; 
  
  location / { 
    root /var/www/html; 
    index index.html; 
  }
}

Example as reverse proxy

server { 
  listen 80; 
  server_name api.example.com; 
  
  location / { 
    proxy_pass http://localhost:3000; 
    proxy_set_header Host $host; 
    proxy_set_header X-Real-IP $remote_addr; 
  }
}

Nginx Startup and Commands on Linux

On Linux systems, Nginx is typically installed as a system service and managed via systemd. This allows you to start, stop, and control Nginx in a standardized way and integrated with the operating system.

Starting the Service

To start Nginx:

sudo systemctl start nginx

To check the service status:

sudo systemctl status nginx

Once started, Nginx will be reachable at:

http://localhost

Automatically Start at System Boot

To enable Nginx to automatically start at boot:

sudo systemctl enable nginx

For Disable it:

sudo systemctl disable nginx

Stopping and restarting the service

To stop Nginx:

sudo systemctl stop nginx

To restart Nginx:

sudo systemctl restart nginx

Reload the configuration without downtime

After modifying the configuration files, you can reload Nginx without interrupting active connections:

sudo systemctl reload nginx

This command internally sends a reload to the Nginx master process.

Testing the Configuration

Before reloading or restarting Nginx, it's good practice to verify that the configuration is correct:

sudo nginx -t

If the configuration is valid, Nginx will return a confirmation message and can be safely reloaded.


Installing Nginx on Windows

Although Nginx was born and is primarily used on Unix/Linux systems, it is also possible to install and use it on Windows, especially for development, testing, or local environments.

Download

Nginx for Windows is available as a compressed archive. After downloading the official package, simply extract it to a directory of your choice, for example:

C:\nginx

Directory Structure

Once extracted, the main structure will look like this:

nginx/
   ├── conf/
   ├── html/
   ├── logs/
   └── nginx.exe
  • conf: Contains configuration files (nginx.conf)
  • html: Default directory for static content
  • logs: Access and error log files
  • nginx.exe: Main executable

Starting Nginx

To start Nginx on Windows:

  1. Open the Command Prompt
  2. Navigate to the Nginx directory
  3. Run the command:
nginx.exe

If no errors are displayed, Nginx is running and can be reached at:

http://localhost

Configuration

The main configuration file is located at:

conf/nginx.conf

The syntax and structure of configuration files on Windows are identical to those on Linux, making it easy to switch between different environments.

Limitations of Nginxon Windows

It's important to note that using Nginx on Windows has some limitations:

  • Lower performance compared to Linux
  • Lacks some low-level optimizations
  • Not recommended for production environments

For these reasons, Nginx on Windows is ideal for development and testing, while for production use on Linux systems is strongly recommended.


Note on differences between Linux and Windows

On Linux, Nginx offers the best performance and all the advanced features for production environments. Using systemctl is the recommended method, while the nginx -s commands are more common in advanced or troubleshooting contexts.


-s flag

The -s option in Nginx commands means signal.

It is used to send a signal to an already running Nginx process, instead of starting a new one. For example:
“Send stop signal to the currently running Nginx process”

Nginx uses a master process, which receives these signals and propagates them to worker processes.

Using nginx -s commands on Linux

As an alternative to systemctl, you can use native Nginx commands directly (with the -s option):

  • Immediate shutdown:
    sudo nginx -s stop
  • Gentle shutdown:
    sudo nginx -s quit
  • Reload configuration:
    sudo nginx -s reload
  • Reopening log files:
    sudo nginx -s reopen

Using nginx -s commands on Windows

Some useful commands to always run from the Nginx directory:

  • Stop Nginx:
    nginx -s stop
  • Reload the configuration:
    nginx -s reload
  • Force termination:
    nginx -s quit

Is Nginx an application server?

Short answer: No, Nginx is not an application server.


Why Nginx is not an application server

An application server:

  • executes application code
  • handles business logic
  • provides runtimes (JVM, Node.js, PHP, etc.)

Examples:

  • Tomcat / WildFly (Java)
  • Node.js
  • .NET Kestrel
  • PHP-FPM

Nginx does not execute application code and does not provide a runtime for general-purpose programming languages.

Why it's often confused with an application server

Nginx can:

  • route dynamic requests
  • communicate with application processes
  • use modules (e.g., FastCGI, uWSGI)

This makes it an integral part of the application architecture, but does not turn it into an application server.

Examples:

  • with PHP → Nginx + PHP-FPM
  • with Java → Nginx + Tomcat
  • with Node.js → Nginx + Express

In all these cases, Nginx is the HTTP front-end, while the application server is the backend.


So what is Nginx, really?

We can define it as:

A high-performance web server and reverse proxy, specialized in handling HTTP traffic, not executing application logic.

It's a fundamental layer of modern infrastructure, but it works alongside application servers, not in place of them.


Conclusion

Nginx is an extremely powerful and versatile tool:

  • Brighteningly fast at serving static content
  • Excellent as a reverse proxy and load balancer
  • Essential for scalable architectures

However, it is not an application server, because it does not execute application code or provide a runtime environment.

Understanding this distinction helps design more robust, scalable, and maintainable architectures.



Follow me #techelopment

Official site: www.techelopment.it
facebook: Techelopment
instagram: @techelopment
X: techelopment
Bluesky: @techelopment
telegram: @techelopment_channel
whatsapp: Techelopment
youtube: @techelopment