Serve a static site
Write a server block that listens on port 80 and serves /var/www/site with index.html as the default file. Validate with nginx -t, then reload safely.
Backend & Runtime / Knowledge library
event-driven reverse proxy and web server
NGINX serves static files quickly and handles high concurrency with low memory use. It is widely used as a reverse proxy to route requests to app servers, terminate TLS, load balance traffic, cache responses, and enforce limits.
Created by Igor Sysoev to solve C10k-style concurrency limits. First public release was in 2004. NGINX, Inc. was founded in 2011 to support commercial adoption. F5 acquired NGINX in 2019.
Work through these exercises in order. Try the task before opening a reference.
Write a server block that listens on port 80 and serves /var/www/site with index.html as the default file. Validate with nginx -t, then reload safely.
Route /api/ traffic to a local Node service on port 3000. Preserve Host and client IP headers. Confirm behavior with curl and access logs.
Create an upstream with two app servers, proxy / to it, enable rate limiting for bursts, and add security headers for common browser protections.
Model blue/green upstream pools and switch traffic with minimal downtime using a single config change plus reload.
Configure short-lived proxy cache for GET responses and bypass cache on Authorization headers. Measure hit ratio from logs.
A growing logistics firm managing a fleet of microservices that handle real-time tracking, inventory updates, and customer notifications.
The firm faces inconsistent request handling and security overhead because each microservice independently manages its own SSL termination, authentication, and rate limiting, leading to fragmented security policies and increased maintenance complexity.
By deploying NGINX as a centralized reverse proxy, the firm can offload SSL termination, authentication, and request routing to a single entry point. This event-driven architecture ensures that all incoming traffic is validated and routed consistently before reaching internal services, simplifying the security posture and reducing redundant logic in application code.
This diagram illustrates how external requests are processed by NGINX before being distributed to internal microservices.
Initiates HTTP/HTTPS requests
Handles SSL, Auth, and Routing
Internal microservice
Internal microservice
This configuration demonstrates defining an upstream group for load balancing and using proxy_pass to route traffic, which addresses the problem of inconsistent request handling.
upstream backend_services { server 10.0.0.1; server 10.0.0.2; } # Define backend pool
server { listen 443 ssl; # Centralized SSL termination
location / { proxy_pass http://backend_services; # Forwarding traffic } }A streamlined infrastructure where security and traffic management are decoupled from application logic, resulting in easier policy updates and uniform request handling across the entire service ecosystem.
The primary limitation is that the centralized proxy can become a single point of failure or a bottleneck if not scaled horizontally; administrators should monitor the error logs and use the ngx_http_stub_status_module to track active connections and identify potential saturation.