Sitemap

Understanding NGINX

4 min read5 days ago

--

Press enter or click to view image in full size
Simple illustration of NGINX

Understanding NGINX: What I Learned as a DevOps Beginner

Exploring how websites handle requests, manage traffic, and deliver content using NGINX.

When I started exploring DevOps, I came across many unfamiliar tools and technologies. One of them was NGINX.

At first, I thought NGINX was simply a tool used to run websites. But as I started learning more, I realized it could do much more than that.

So, I wanted to share my understanding of NGINX in simple terms, especially for anyone who is also beginning their DevOps journey.

What Exactly Is NGINX?

NGINX (pronounced “engine-x”) is an open-source software commonly used as a web server, reverse proxy, load balancer, and HTTP cache.

That sounds like a lot of technical terms, right?

Let’s understand them one by one.

Imagine you open a website in your browser.

Your browser sends a request asking for the website’s content. A server receives that request and sends back a response.

NGINX can help manage this communication between users and servers.

Depending on how it is configured, NGINX can serve website files directly or forward requests to another application.

1. NGINX as a Web Server

Let’s start with the simplest role.

Imagine you created a small website using HTML, CSS, and JavaScript.

When someone visits your website, they need to receive those files to display the page.

NGINX can act as a web server and deliver those files to the user’s browser.

Simple example:

  • A user opens www.mywebsite.com
  • The browser sends a request.
  • NGINX receives the request.
  • NGINX returns the requested website files.
  • The browser displays the website.

This is one of the basic ways NGINX can be used.

2. NGINX as a Reverse Proxy

This was one of the most interesting concepts I came across.

Imagine you have an online shopping application.

The application has a backend server that handles things like product information, user accounts, and orders.

Instead of users communicating directly with the backend, NGINX can sit in front of it.

When a user sends a request, NGINX receives it and forwards it to the appropriate backend server.

The backend processes the request and sends its response through NGINX.

This is called a reverse proxy.

Why is this useful?

  • It provides a single entry point for requests.
  • It can route requests to different backend services.
  • It can handle HTTPS connections when configured to do so.
  • It can keep backend servers from being directly exposed to the public internet.

One thing I learned is that a reverse proxy is useful for organizing application traffic, but it does not automatically make an application completely secure.

3. NGINX as a Load Balancer

Now imagine our online shopping application becomes popular.

At first, we might have only one backend server.

Get Parami Gunasekara’s stories in your inbox

Join Medium for free to get updates from this writer.

But what happens when thousands of users try to access the application?

A single server might struggle to handle all the requests.

One possible solution is to use multiple backend servers.

NGINX can act as a load balancer, distributing incoming requests among those servers.

For example:

  • User A’s request goes to Server 1.
  • User B’s request goes to Server 2.
  • User C’s request goes to Server 3.

This can help share the workload instead of sending everything to one server.

NGINX supports different methods for distributing requests, depending on the configuration.

I found this concept useful because it helped me understand how applications can be designed to handle increasing traffic.

Of course, load balancing alone does not guarantee that an application will always remain available. The backend servers and other parts of the system also matter.

4. NGINX and Caching

Another interesting feature is caching.

Imagine a website receives repeated requests for the same content.

Without caching, the application might need to generate the same response again and again.

NGINX can be configured to store certain responses temporarily and reuse them for later requests.

This is called caching.

For example, if many users request the same cacheable content, NGINX may be able to return a stored response instead of contacting the backend every time.

Why does caching matter?

  • It can reduce repeated work on backend servers.
  • It can improve response times for cached content.
  • It can help reduce unnecessary server traffic.

However, not everything should be cached. Content that changes frequently or contains private user information requires careful handling.

Where Does NGINX Fit into DevOps?

As someone learning DevOps, I wanted to understand why NGINX appears so often in discussions about application deployment.

NGINX can be useful in several situations.

Application deployment: It can serve frontend files or forward requests to backend applications.

Docker environments: NGINX can run inside a container and communicate with other application containers.

Traffic management: It can route incoming requests to the correct services.

Scaling applications: It can distribute requests across multiple backend servers.

HTTPS: It can manage encrypted connections when configured with the appropriate certificates.

One important thing I understood is that NGINX is not a complete DevOps solution by itself.

It is one component that can work alongside technologies such as Docker, CI/CD pipelines, cloud infrastructure, and monitoring tools.

My Key Takeaways

Before learning about NGINX, I mainly thought about websites from a developer’s perspective: writing code and making the application work.

Learning these concepts helped me start thinking about what happens after an application is developed.

How do users access it? How are requests handled? What happens when traffic increases?

NGINX helped me connect these questions to real infrastructure concepts.

  • A web server can deliver website content to browsers.
  • A reverse proxy can forward requests to backend applications.
  • A load balancer can distribute traffic across multiple servers.
  • Caching can reduce repeated backend work for suitable content.

This article is based on my current understanding while learning DevOps. I’m sharing it as part of my learning journey, and I look forward to improving my knowledge through practical experience.

--

--