Location Matching & Rewrites
Can you walk through the full order in which NGINX evaluates location matches (exact, prefix, regex, priority prefix)?
Explain the purpose and precedence of location blocks in Nginx configuration (prefix, exact, regex matches).
How would you configure NGINX to serve a single-page application while proxying /api requests to a backend?
What are named locations (@name) in NGINX and when would you use them?
What does the ^~ priority prefix modifier do in a location block and how does it change matching precedence?
What is the difference between an NGINX location block and an NGINX rewrite rule?
What is the difference between rewrite and redirect in NGINX?
What is the difference between the Nginx rewrite and return directives, when would you use each, and what are the flags for rewrite?
Static Content Serving
Describe how NGINX is used to serve both static and dynamic content efficiently.
Explain the purpose and use of the try_files directive.
How does NGINX determine and serve the correct MIME type for a static file?
How does Nginx serve static content efficiently, and what do directives like root, alias, index, and try_files do?
How does the sendfile directive improve static file serving performance in NGINX?
What does the autoindex directive do and when should it be enabled?
What is the difference between the root and alias directives in Nginx?
What is the purpose of the 'expires 7d;' directive in NGINX configuration?
Ssl Tls & Https
Describe the process of configuring Nginx for SSL/TLS termination and important considerations for security and performance.
Explain the concept of SNI (Server Name Indication) in the context of Nginx TLS termination.
How do HSTS headers get configured in NGINX and what do they enforce?
How do you configure mutual TLS (client certificate authentication) in NGINX?
How do you enable HTTP/2 in NGINX and what benefits does it bring?
What is required to enable HTTP/3 (QUIC) in NGINX and how does it differ from HTTP/2?
What is the difference between SSL session cache and session tickets in NGINX, and how do they affect performance?
What techniques would you use to optimize SSL/TLS performance in NGINX (session caching, OCSP stapling, modern ciphers)?
Which directive should be used in NGINX to enforce HTTPS and automatically redirect HTTP requests to HTTPS?
Which NGINX directive is used to specify the file path to the SSL certificate?
Compression
Does NGINX support compressing requests to the upstream (e.g., via the gunzip module)?
How can you configure gzip or Brotli compression in Nginx and what are its benefits?
What is gzip_static and how does it differ from on-the-fly gzip compression?
Which directive in NGINX excludes specific file types from compression?
Reverse Proxy & Api Gateway
Explain how Nginx handles client_max_body_size and its implications when Nginx acts as a reverse proxy in front of an application server.
How do Nginx's proxy_set_header directives work, particularly for Host, X-Forwarded-For, and X-Forwarded-Proto?
How do proxy_hide_header and proxy_pass_header control which headers reach the client?
How do proxy_read_timeout, proxy_connect_timeout, and proxy_send_timeout differ in NGINX?
How does Nginx function as a reverse proxy, and what are the key directives involved?
How does NGINX handle WebSocket connections?
How does NGINX proxy to a PHP-FPM backend using fastcgi_pass and fastcgi_param?
How does request body buffering work in NGINX and what are the implications of disabling it with proxy_request_buffering?
How does the trailing slash on proxy_pass affect how the request URI is passed to the upstream?
How is NGINX used as an API gateway and what features make it suitable for that role?
What are the benefits of using Nginx as a reverse proxy?
What does the proxy_redirect directive do and when is it needed?
What is an upstream block in Nginx and what is its purpose?
What is proxy buffering in NGINX, and how do proxy_buffers and related directives affect performance?
What is the difference between proxy_pass, fastcgi_pass, uwsgi_pass, and grpc_pass in NGINX?
What is the relationship and function of Nginx and Ingress controllers in Kubernetes?
What is the resolver directive and why is it needed for dynamic upstream DNS resolution in NGINX?
Virtual Hosts & Server Blocks
Explain how Nginx handles virtual hosts using server blocks and server_name matching.
How can you restrict undefined server name processing in NGINX?
How does NGINX prioritize exact, wildcard, and regex server_name matches?
How does the default_server flag and the listen directive determine which server block handles a request?
Modules Signals & Rate Limiting
Explain the limit_conn and limit_rate directives for controlling connections and bandwidth in Nginx.
How are modules handled in Nginx (static vs. dynamic compilation)?
How do you configure Nginx for rate limiting, and how do limit_req_zone and limit_req work with the underlying leaky bucket algorithm?
How does Nginx achieve zero-downtime configuration reloads and binary upgrades?
What are dynamic modules in NGINX and how does load_module work?
What are OpenResty/Lua and njs, and how do they extend NGINX's capabilities?
What does the burst and nodelay parameter do in NGINX rate limiting, and how does it affect the leaky bucket behavior?
What is worker_shutdown_timeout and how does graceful shutdown work during an NGINX reload?
What role do the HUP, USR2, and WINCH signals play in controlling the NGINX master process?
Fundamentals & Architecture
Explain the NGINX Master and Worker processes and their respective roles.
How does NGINX handle HTTP requests internally, particularly its event-driven, asynchronous, and non-blocking architecture?
How does NGINX use epoll (or kqueue) as its event notification mechanism, and why does that matter for concurrency?
What are the benefits of using NGINX in a web infrastructure?
What are the primary differences between NGINX and Apache, especially regarding their architectural models for handling connections?
What are the types of NGINX versions (Mainline vs. Stable) and when would you use each?
What is Nginx and what are its primary use cases?
What is NGINX Unit and how does it differ from NGINX as a web server?
What is the C10k problem that NGINX was designed to solve?
What is the difference between Nginx Open Source and Nginx Plus?
Logging Monitoring & Troubleshooting
Explain the purpose and use of the stub_status module for monitoring NGINX.
How can you configure conditional logging or disable access logging for certain requests in NGINX?
How can you debug NGINX issues effectively?
How is the error_page directive used to customize error responses in NGINX?
What are the different error_log severity levels in NGINX and when would you raise or lower them?
What is the difference between a 502, 504, and 499 error in NGINX, and what does each indicate?
What is the difference between the combined log format and a custom log_format in NGINX?
What is the NGINX access log and what information does it typically contain?
What is the purpose of the error_log and access_log directives in Nginx, and how can you customize logging?
What steps would you take to troubleshoot a 502 Bad Gateway error in NGINX?
Performance Tuning
How do keepalive_timeout and keepalive_requests affect client connection reuse in NGINX?
What are keepalive connections in NGINX and why are they important?
What are some key Nginx directives for performance tuning under heavy load, such as worker_processes, worker_connections, keepalive_timeout, sendfile, tcp_nopush, and tcp_nodelay?
What is the significance of the worker_rlimit_nofile directive in Nginx?
Load Balancing & Health Checks
How do max_fails and fail_timeout implement passive health checks in an NGINX upstream?
How do server weights influence NGINX load balancing?
How do the hash, random, and least_time load balancing methods work in NGINX and when would you use them?
How do you configure session persistence (sticky sessions) in NGINX and which methods require NGINX Plus?
How does Nginx handle load balancing, and what are the different load balancing methods available (round-robin, least_conn, ip_hash) and when would you choose each?
How would you implement blue-green or canary deployments using NGINX upstreams and weights?
What are the main differences between NGINX and HAProxy for load balancing?
What do the backup and down flags do on upstream servers in NGINX?
What is the difference between passive and active health checks in NGINX, and which requires NGINX Plus?
What is the stream module in NGINX and how does it enable L4 TCP/UDP proxying and load balancing?
Why should you configure keepalive connections to upstream servers, and how does the keepalive directive in an upstream block work?
Caching
How do you implement caching in Nginx using proxy_cache, and what are cache keys and cache zones?
How do you purge or invalidate cached content in NGINX?
How does NGINX decide what to cache based on upstream Cache-Control headers, and how can you override that behavior?
What are the different types of caching mechanisms available in NGINX?
What does proxy_cache_use_stale do and why is serving stale cached content useful?
What is cache locking (proxy_cache_lock) in NGINX and what problem does it solve?
What is fastcgi_cache and how does it differ from proxy_cache?
What is microcaching in Nginx and when would it be beneficial?
Security & Access Control
How do you secure NGINX from common vulnerabilities and harden its configuration?
How do you use allow and deny directives for IP-based access control in NGINX?
How does auth_basic with an htpasswd file work in NGINX?
How would you configure Nginx to prevent the exposure of server version or other sensitive information?
What is the auth_request module and how does it enable sub-request based authentication in NGINX?
Configuration Structure
How do you test an NGINX configuration before applying it, and what does nginx -t do?
How does directive inheritance work across nested contexts in NGINX, and what happens when a directive is redefined in a child block?
What are the key components and hierarchical structure of an NGINX configuration file (main, events, http, server, location, upstream contexts)?
What is a directive in NGINX?
What is the purpose of the include directive and the conf.d / sites-available / sites-enabled convention in NGINX?
Which context should the ssi directive be placed in to enable Server Side Includes?
Variables & Conditional Logic
How does the map directive create derived variables, and why is it preferred over if for conditional logic?
What are Nginx variables, and how are they used in configurations for dynamic behavior? Provide examples of common built-in variables.
What are the geo and map modules in NGINX and how are they used to create conditional variables?
Why is 'if' considered evil in NGINX, and when is it safe to use it?