Nginx Reverse Proxy Guide + Interview Questions

English + हिन्दी | TechWithAdi

What is Nginx?

Nginx is a high-performance web server, reverse proxy and load balancer.

What is a Reverse Proxy?

A reverse proxy receives requests from users and forwards them to backend applications.

Install Nginx

sudo apt install nginx -y

Check Status

sudo systemctl status nginx

Sample Reverse Proxy Configuration

server {
    listen 80;

    location / {
        proxy_pass http://127.0.0.1:8000;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
    }
}

Test Configuration

sudo nginx -t

Restart Nginx

sudo systemctl restart nginx

Benefits

  • Improved security
  • Load balancing
  • SSL termination
  • Performance optimization

Top 20 Nginx Interview Questions

Q1. What is Nginx?

High-performance web server and reverse proxy.

Q2. What is a Reverse Proxy?

Forwards client requests to backend servers.

Q3. Difference between Nginx and Apache?

Nginx uses event-driven architecture.

Q4. What is proxy_pass?

Directive used to forward requests.

Q5. How do you test configuration?

nginx -t

Q6. How do you restart Nginx?

systemctl restart nginx

Q7. What is load balancing?

Distributes traffic across servers.

Q8. What is SSL termination?

Handles SSL at proxy layer.

Q9. What is a server block?

Equivalent to Apache VirtualHost.

Q10. Where is nginx.conf located?

Usually /etc/nginx/nginx.conf

Q11. How do you view logs?

Check access.log and error.log

Q12. What is upstream?

Defines backend servers.

Q13. How do you enable gzip?

Using gzip directives.

Q14. What is caching?

Stores content for faster delivery.

Q15. How do you redirect HTTP to HTTPS?

Using return 301 directive.

Q16. What causes 502 Bad Gateway?

Backend service unavailable.

Q17. How do you secure Nginx?

Use SSL, firewall and updates.

Q18. How do you reload configuration?

systemctl reload nginx

Q19. Best practices?

Monitoring, SSL and backups.

Q20. Explain reverse proxy workflow.

Client → Nginx → Backend → Client.

Nginx Reverse Proxy Guide

Nginx एक high-performance web server और reverse proxy है।

sudo apt install nginx -y

Top 20 Nginx Interview Questions

प्रश्न 1. Nginx क्या है?

High-performance web server और reverse proxy।

प्रश्न 2. Reverse Proxy क्या है?

Client requests backend servers को forward करता है।

प्रश्न 3. Nginx और Apache में अंतर?

Nginx event-driven architecture उपयोग करता है।

प्रश्न 4. proxy_pass क्या है?

Request forwarding directive।

प्रश्न 5. Configuration test कैसे करें?

nginx -t

प्रश्न 6. Nginx restart कैसे करें?

systemctl restart nginx

प्रश्न 7. Load balancing क्या है?

Traffic distribute करना।

प्रश्न 8. SSL Termination क्या है?

SSL handling proxy layer पर।

प्रश्न 9. Server Block क्या है?

Apache VirtualHost जैसा।

प्रश्न 10. nginx.conf कहाँ होती है?

/etc/nginx/nginx.conf

प्रश्न 11. Logs कैसे देखें?

access.log और error.log

प्रश्न 12. Upstream क्या है?

Backend servers define करता है।

प्रश्न 13. Gzip कैसे enable करें?

gzip directives से।

प्रश्न 14. Caching क्या है?

Content cache करना।

प्रश्न 15. HTTP को HTTPS पर redirect कैसे करें?

return 301

प्रश्न 16. 502 Bad Gateway क्यों आता है?

Backend unavailable।

प्रश्न 17. Nginx secure कैसे करें?

SSL, firewall और updates।

प्रश्न 18. Configuration reload कैसे करें?

systemctl reload nginx

प्रश्न 19. Best practices क्या हैं?

Monitoring, SSL, backups।

प्रश्न 20. Reverse proxy workflow समझाइए।

Client → Nginx → Backend → Client।