Posted in

Top 30 Nginx Interview Questions and Answers for All Experience Levels

Master Nginx Concepts from Basic to Advanced

Prepare for your next Nginx interview with these 30 carefully curated questions covering conceptual, practical, and scenario-based topics. Questions progress from basic to advanced, suitable for freshers, 1-3 years, and 3-6 years experienced candidates.

Basic Nginx Questions (1-10)

1. What is Nginx?

Nginx is a high-performance web server, reverse proxy, load balancer, and HTTP cache. It efficiently handles thousands of concurrent connections using an event-driven architecture.[1][4]

2. In what programming language is Nginx written?

Nginx is written in the C programming language, which contributes to its high performance and low memory usage.[4][5]

3. What are the main tasks of the Nginx web server?

The main tasks include deploying dynamic HTTP content using FastCGI, SCGI, or WSGI handlers, and serving as a load balancer for high-traffic applications.[4][5]

4. What is the master process in Nginx?

The master process performs privileged operations such as reading configuration files and binding to ports. It manages worker processes but doesn’t handle client requests.[4][5]

5. What is a worker process in Nginx?

Worker processes handle actual client requests. Each worker process is single-threaded and uses an event-driven approach to process multiple connections efficiently.[4][5]

6. How do you check the version of Nginx?

Use the command nginx -v to display the installed Nginx version.[8]

7. What is the purpose of the -s parameter with Nginx?

The -s parameter sends signals to the Nginx master process, such as nginx -s reload to reload configuration or nginx -s stop to stop the server.[4][5]

8. What does the stub_status directive do in Nginx?

The stub_status directive provides real-time status information including active connections, total connections accepted, and current read/write/wait connections.[4]

9. What are the main control signals used with Nginx?

Main signals include stop, quit, reopen (log files), and reload (graceful configuration reload).[4][5]

10. What problem was Nginx originally created to solve?

Nginx was created to solve the C10K problem – handling 10,000 concurrent client connections efficiently, which traditional servers struggled with.[5]

Intermediate Nginx Questions (11-20)

11. How do you configure a basic Nginx server block?

Create a server block in nginx.conf with directives like server_name, listen port, and root directory:

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

[1]

12. What is a reverse proxy in Nginx?

A reverse proxy forwards client requests to backend servers. Nginx terminates client connections and creates new connections to upstream servers.[2][3]

13. How do you set up Nginx as a reverse proxy?

Configure proxy_pass directive pointing to backend servers:

location / {
    proxy_pass http://backend-server:8080;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
}

[1][2]

14. What is an upstream block in Nginx?

The upstream block defines a group of backend servers for load balancing. Multiple servers can be listed with IP addresses and ports.[2]

15. How do you configure load balancing in Nginx?

Define upstream servers and use proxy_pass:

upstream backend {
    server 192.168.1.10;
    server 192.168.1.11;
}
server {
    location / {
        proxy_pass http://backend;
    }
}

[2][3]

16. What load balancing methods does Nginx support?

Nginx supports round-robin (default), least connections, IP hash, weighted round-robin, and backup servers.[2][3]

17. How do you enable gzip compression in Nginx?

Add gzip directives in the http block:

http {
    gzip on;
    gzip_types text/plain text/css application/json;
    gzip_min_length 256;
}

[2][3]

18. How do you debug Nginx configuration issues at Zoho?

Test configuration with nginx -t, check error logs in /var/log/nginx/error.log, and use nginx -T to dump entire configuration.[1]

19. What is the purpose of proxy_set_header in Nginx?

proxy_set_header forwards client information like Host, X-Real-IP, and X-Forwarded-For to backend servers.[2]

20. How do you configure Nginx caching?

Use proxy_cache_path and proxy_cache directives:

proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=my_cache:10m;
server {
    location / {
        proxy_cache my_cache;
        proxy_pass http://backend;
    }
}

[2]

Advanced Nginx Questions (21-30)

21. How do you configure weighted load balancing in Nginx for Paytm’s high-traffic environment?

Use weight parameter in upstream:

upstream paytm_backend {
    server 10.0.1.1 weight=3;
    server 10.0.1.2 weight=2;
    server 10.0.1.3 weight=1 backup;
}

[2]

22. What is SSL termination in Nginx?

SSL termination occurs when Nginx decrypts HTTPS traffic from clients and forwards plain HTTP to backend servers, reducing backend load.[2][3]

23. How do you optimize SSL/TLS performance in Nginx?

Enable session caching, session tickets, OCSP stapling, and modern ciphers:

ssl_session_cache shared:SSL:10m;
ssl_session_tickets on;
ssl_stapling on;

[3]

24. How do you configure Nginx for static content serving at Flipkart scale?

Set root directory, enable caching, and compression:

location ~* \.(jpg|jpeg|png|css|js)$ {
    root /var/www/static;
    expires 1y;
    add_header Cache-Control "public, immutable";
}

[1]

25. What is the least_conn load balancing method?

least_conn directs new connections to the server with the fewest active connections, ideal for backends with long-running connections.[3]

26. How do you implement health checks for upstream servers in Nginx?

Use health_check directive in the upstream block (requires nginx-plus or third-party modules):

upstream backend {
    server backend1.example.com max_fails=3 fail_timeout=30s;
}

[3]

27. How would you reduce latency for Salesforce’s Nginx deployment?

Implement caching, enable gzip compression, optimize SSL settings, tune worker processes, and use keepalive connections.[3]

28. What is the IP hash load balancing method?

IP hash assigns requests from the same client IP to the same backend server using a hash of the client IP address.[3]

29. How do you configure rate limiting in Nginx for Swiggy’s API endpoints?

Use limit_req_zone and limit_req:

http {
    limit_req_zone $binary_remote_addr zone=api:10m rate=10r/s;
}
server {
    location /api/ {
        limit_req zone=api burst=20;
        proxy_pass http://backend;
    }
}

30. How do you horizontally scale Nginx for Adobe’s global traffic?

Use multiple Nginx instances behind a load balancer, optimize worker_processes to CPU cores, enable caching, and monitor with stub_status.[3]

Master these 30 Nginx interview questions to confidently handle interviews across freshers to experienced levels. Practice configuring these scenarios hands-on for best results.

Leave a Reply

Your email address will not be published. Required fields are marked *