# How Web Servers Serve Traffic

> Understand what a web server does in front of an application: static files, virtual hosts, TLS termination, proxying, caching and logging. Free notes, key...

Canonical: https://www.internhack.in/roadmaps/tracks/devops/web-server-concepts
Last updated: 2026-11-28

Understand what a web server does in front of an application: static files, virtual hosts, TLS termination, proxying, caching and logging.

Beginner · about 3 hours · difficulty 2/5

Learn first: [HTTP and HTTPS](https://www.internhack.in/roadmaps/tracks/devops/http-https), [Load Balancing and Proxies](https://www.internhack.in/roadmaps/tracks/devops/load-balancing-proxies)

Application runtimes like Node, Gunicorn or a Java server are rarely exposed to the internet directly. A web server or reverse proxy sits in front and handles the jobs it is better at.

### Responsibilities

- **Static content**: serving files efficiently with correct caching headers and compression.
- **Virtual hosts**: many sites on one server, selected by the `Host` header or SNI.
- **TLS termination**: decrypt once at the edge, then forward plain HTTP or re-encrypt.
- **Reverse proxying** to upstream app servers, with timeouts, buffering and retries.
- **Protection**: rate limits, request size limits, basic auth, IP allow lists, security headers.
- **Access and error logs** in a format your log pipeline can parse (JSON is easiest).

### Architecture choices

Event-driven servers (Nginx, Caddy, HAProxy) handle many connections with few threads; process-per-request models (classic Apache prefork) use more memory. In Kubernetes, these same servers appear as **ingress controllers** and sidecars.

### Pitfalls

Default timeouts that are too short for uploads or too long for a failing backend, missing `X-Forwarded-Proto` so apps generate http:// links, and config changes applied without a syntax check (`nginx -t`).

**Good enough to move on:** you can describe each hop a request takes from browser to app and which component should own caching, TLS and rate limiting.

## Key concepts

- **Static vs dynamic content**
- **Virtual hosts**
- **TLS termination**
- **Upstreams and timeouts**
- **Compression and caching headers**
- **Security headers**
- **Structured access logs**

## Mini project

Sketch and document the request path for a site with a CDN, a load balancer, a web server and two app servers, noting where TLS ends, where logs are written and where caching happens.

## Check yourself

Why does an app behind a TLS-terminating proxy sometimes redirect users to http:// URLs, and how do you fix it?

## Free resources

- [MDN: HTTP caching](https://developer.mozilla.org/en-US/docs/Web/HTTP/Caching) (MDN)
- [What is a reverse proxy?](https://www.cloudflare.com/learning/cdn/glossary/reverse-proxy/) (Cloudflare)

Previous: [Branching Strategies and Pull Requests](https://www.internhack.in/roadmaps/tracks/devops/branching-workflows) · Next: [Nginx](https://www.internhack.in/roadmaps/tracks/devops/nginx)

## More in Web Servers and Reverse Proxies

- [How Web Servers Serve Traffic](https://www.internhack.in/roadmaps/tracks/devops/web-server-concepts)
- [Nginx](https://www.internhack.in/roadmaps/tracks/devops/nginx)
- [Caddy](https://www.internhack.in/roadmaps/tracks/devops/caddy)
- [HAProxy](https://www.internhack.in/roadmaps/tracks/devops/haproxy)
- [Apache HTTP Server](https://www.internhack.in/roadmaps/tracks/devops/apache)

## Related

- [Roadmaps](https://www.internhack.in/roadmaps)
- [DevOps Engineer Roadmap](https://www.internhack.in/roadmaps/tracks/devops)
