# Nginx + DNS Explained for DevOps Beginners (With Real-World Examples)

If you are learning DevOps, two topics will come again and again:

✅ **Nginx** (Web server + Reverse Proxy)  
✅ **DNS** (Domain → IP resolution)

Today I learned both, and in this blog I’m sharing my notes in a clean way with extra real-world understanding, so it can help other DevOps learners too.

***👋 If you found this article helpful and want to follow my DevOps learning journey,  
connect with me on LinkedIn 👉*** [***RamuChelloj***](https://www.linkedin.com/in/ramuchelloju/)[***u***](https://www.linkedin.com/in/ramuchelloju/)

---

## [1) What](https://www.linkedin.com/in/ramuchelloju/) is Nginx?

**Nginx** is a high-performance web server used to serve static files like:

* HTML
    
* CSS
    
* JavaScript
    
* Images
    

It can also be used as:

✅ **Reverse Proxy**  
✅ **Load Balancer**  
✅ **API Gateway (basic)**  
✅ **TLS/SSL termination**

### Real use in production:

Most companies use Nginx to serve frontend and route requests to backend applications (Node.js, Java, Python, etc.).

---

## 2) Nginx vs Apache (Quick Difference)

Both are web servers, but:

### Apache

* Process/thread-based
    
* Good for dynamic modules
    
* Older and widely used
    

### Nginx

* Event-driven and lightweight
    
* Handles high traffic efficiently
    
* Excellent for reverse proxy and load balancing
    

**DevOps takeaway:**  
Nginx is very common in microservices and modern architectures.

---

## 3) What is a Proxy?

A **proxy** is a middle server that sits between client and server.

### ✅ Forward Proxy (Client Side Proxy)

Forward proxy works on the **client side**.

📌 Use cases:

* VPN
    
* Blocking websites
    
* Monitoring user traffic
    
* Hiding client identity
    

Example:

```plaintext
Client → Forward Proxy → Internet
```

### ✅ Reverse Proxy (Server Side Proxy)

Reverse proxy works on the **server side**.

📌 Use cases:

* Hiding backend server IP
    
* Routing API requests to backend
    
* Load balancing
    
* Security control
    

Example:

```plaintext
Client → Nginx (Reverse Proxy) → Backend App
```

---

## 4) Nginx Reverse Proxy Example (Real Scenario)

Assume we have:

* Frontend is running on **Nginx**
    
* Backend Node.js is running on **port 8080**
    

### Frontend URL:

```plaintext
http://frontend-server
```

### Backend API:

```plaintext
http://backend-server:8080
```

Instead of exposing backend to public, we do reverse proxy in Nginx like this:

```plaintext
location /api/ {
    proxy_pass http://backend-server:8080/;
}
```

Now the user will access backend like:

✅ [`http://frontend-server/api/`  
And](http://frontend-server/api/￼And) Nginx will forward it internally to backend.

---

## 5) Important Nginx Paths (Linux)

These paths are important for every DevOps learner:

### ✅ Configuration folder

```plaintext
/etc/nginx/
```

### ✅ Default configs (commonly used)

```plaintext
/etc/nginx/default.d/
```

Example:

```plaintext
/etc/nginx/default.d/expense.conf
```

### ✅ Default web root (static files location)

```plaintext
/usr/share/nginx/html/
```

### ✅ Nginx logs

```plaintext
/var/log/nginx/
```

* `access.log`
    
* `error.log`
    

---

## 6) What is DNS Resolver?

**DNS Resolver** is responsible for converting:

✅ Domain name → IP Address

Example:

```plaintext
google.com → 142.250.xx.xx
```

Whenever we type a website URL, DNS helps to find the correct server IP.

---

## 7) How DNS Works (Step-by-Step Flow)

When you open a domain in browser, DNS resolution happens in this order:

### ✅ DNS Resolution Flow

1. **Browser Cache**
    
2. **OS Cache**
    
3. **ISP DNS Resolver Cache**
    
4. **Root Servers**
    
5. **TLD Servers**
    
6. **Authoritative Nameserver**
    
7. Returns IP address back to browser
    

---

## 8) Root Servers (Important Concept)

There are **13 Root Servers** worldwide (logical root server identities).

Root servers do not store every domain record, but they know where to find:

✅ **TLD information** (like .com, .in, .net)

Root servers are part of DNS root zone and are under **ICANN management**.

---

## 9) What is TLD?

**TLD = Top Level Domain**

Examples:

* `.com`
    
* `.in`
    
* `.net`
    
* `.org`
    
* `.us`
    
* `.uk`
    
* `.edu`
    
* `.ai`
    
* `.shop`
    
* `.online`
    

### Example:

In [`example.com`](http://example.com)

* `example` = domain name
    
* `.com` = TLD
    

---

## 10) What is a Domain Registrar?

A **Domain Registrar** is a company where we can buy and manage domains.

Examples:

* GoDaddy
    
* Hostinger
    
* Porkbun
    
* AWS Route53 (Domain registration + DNS)
    

📌 You can also transfer your domain from one registrar to another.

---

## 11) Domain Purchase Flow (What Happens in Background?)

Let’s say you buy:

✅ [`ramu.com`](http://ramu.com)

### Steps:

1. You check domain availability in registrar
    
2. Registrar checks with the TLD registry
    
3. Payment completed → domain gets assigned to buyer
    
4. Registrar updates domain ownership and details
    
5. You configure DNS records like **A record**
    
6. Changes propagate based on TTL
    

---

## 12) DNS Records You Must Know

### ✅ A Record

Maps domain to IPv4 address

Example:

```plaintext
ramu.com → 54.12.34.56
```

### ✅ NS Record (Name Server Record)

Tells which DNS servers manage the domain.

Example:

```plaintext
ns-123.awsdns-45.com
ns-456.awsdns-12.net
```

### ✅ TTL (Time To Live)

TTL means how long the DNS response is cached.

Example:

* TTL = 3600 seconds = 1 hour
    

---

## 13) TTL Practical Real-World Tip

If you are changing IP address (migration / deployment):

✅ Keep TTL **low** (like 60 seconds)  
So DNS changes update faster.

After everything is stable:

✅ Set TTL back to **3600s (1 hour)**

---

## 14) AWS Route53 (Easy Explanation)

Route53 is AWS DNS service.

### Typical flow:

1. Create **Public Hosted Zone** in Route53
    
2. Route53 gives you **NS records**
    
3. Update those NS records at your domain registrar
    
4. Now Route53 becomes responsible for your DNS
    

After that you can create:

* A record
    
* CNAME
    
* TXT
    
* etc.
    

---

## 15) Useful DNS Command

To check domain resolves correctly:

```plaintext
nslookup yourdomain.com
```

Example:

```plaintext
nslookup servicowiz.in
```

Output will show the IP address.

---

## ✅ Quick Revision Summary

### Nginx

* Web server for static content
    
* Reverse proxy for backend services
    
* Config in `/etc/nginx/`
    
* Web root `/usr/share/nginx/html/`
    

### DNS

* Converts domain → IP
    
* Uses caching (browser → OS → ISP)
    
* Root → TLD → Authoritative NS
    
* A record maps domain → IP
    
* TTL controls caching duration
    

---

## 🎯 Interview Questions (Must Prepare)

✅ What is Nginx and why is it used?  
✅ Difference between forward proxy and reverse proxy  
✅ Explain DNS resolution flow step-by-step  
✅ What are root servers and how many are there?  
✅ What is TLD?  
✅ What is a domain registrar?  
✅ What is A record and NS record?  
✅ What is TTL and why we change it?

---

## ✅ Final Thoughts

Learning **Nginx + DNS** gave me clear understanding of how real web applications work:

* Frontend served by Nginx
    
* Backend routed via reverse proxy
    
* Domains mapped using DNS records
    

This is a strong foundation for DevOps and Cloud.

---
