Your DevOps study space

Real explanations. Videos with tests. Fresh exams every time. Keep the streak alive and watch the XP stack up.

Load balancers, proxies & CDNs · Networking Docs · StackwisePlanDevOps Load balancers, proxies & CDNs · Networking Docs · StackwiseCodePython Load balancers, proxies & CDNs · Networking Docs · StackwiseBuildDocker Load balancers, proxies & CDNs · Networking Docs · StackwiseTestDevOps Load balancers, proxies & CDNs · Networking Docs · StackwiseReleaseGit Load balancers, proxies & CDNs · Networking Docs · StackwiseDeployKubernetes Load balancers, proxies & CDNs · Networking Docs · StackwiseOperateLinux Load balancers, proxies & CDNs · Networking Docs · StackwiseMonitorDevOps

Pick a topic

Eight tracks, each with docs, a cheat sheet, videos and tests.

How it works

One loop, repeated until it sticks.

Jump back in

Picked up from where you left off.

Free forever

Your DevOps journey starts with one click.

Sign in with Google or GitHub to open every chapter, video, test and challenge. Your progress is saved wherever you learn.

Load balancers, proxies & CDNs

Between a browser and your app there are usually several middlemen: a CDN edge, a cloud load balancer, a reverse proxy. The Security & infrastructure chapter introduced them in a paragraph; here you'll see how each works, configure Nginx as a load balancer, and learn how caching headers decide what a CDN keeps.

Forward vs reverse proxy

  • A forward proxy works for clients: outgoing traffic from a company network goes through it, and websites see the proxy's IP. Used for filtering and controlling outbound access; tools that read HTTPS_PROXY use one.
  • A reverse proxy works for servers: it sits in front of your apps, and clients never see the backends. Nginx, HAProxy, Traefik, Caddy and Envoy are common ones.

The reverse proxy handles jobs you don't want in every app: TLS termination, routing by hostname or path, compression, caching, rate limiting. Since the app now sees the proxy as the client, the proxy passes the original details in headers: X-Forwarded-For (client IP plus each proxy on the way), X-Forwarded-Proto (http or https) and often X-Real-IP.

Layer 4 vs layer 7

Layer 4Layer 7
SeesIPs and ports of TCP/UDP connectionsThe HTTP request: host, path, headers, cookies
TLSUsually passes encrypted bytes throughTerminates TLS to read the request
Good forAny protocol (databases, raw TCP), huge throughputWebsites and APIs, path routing, retries, headers
ExamplesAWS NLB, HAProxy TCP mode, Nginx streamAWS ALB, Nginx http, Kubernetes Ingress

Algorithms, health checks, sticky sessions

  • Round robin (the usual default): 1, 2, 3, 1, 2, 3… Fair when requests cost about the same. Weighted: weight=3 gets three times the share.
  • Least connections: next request to the server with the fewest active connections. Better when some requests are slow.
  • IP hash / consistent hashing: the same client (or key) always lands on the same server.

Active health checks call an endpoint like /healthz every few seconds and remove a server after several failures in a row; passive checks watch real traffic for errors. AWS ALB, HAProxy and Kubernetes probes do active checks; open-source Nginx does passive only (active checks are an NGINX Plus feature). A good health endpoint returns 200 only when the app can really serve, e.g. it can reach its database.

Sticky sessions pin each user to one backend (by cookie or IP hash), a workaround for apps that keep sessions in memory. The cost: uneven load, and users are logged out when their server dies. The real fix is a stateless app with sessions in Redis or a database.

requestsload balancerround robinchecks /healthzapp-1200 OKapp-2200 OKapp-3failing: out
Health checks are what make a load balancer safe: a broken server drops out of the rotation by itself and rejoins once it passes again.

Nginx as a load balancer

# /etc/nginx/conf.d/app.conf
upstream app_backend {
    least_conn;                                  # default would be round robin
    server 10.0.2.11:3000 max_fails=3 fail_timeout=30s;
    server 10.0.2.12:3000 max_fails=3 fail_timeout=30s;
    server 10.0.2.13:3000 backup;                # only used if the others are down
}

server {
    listen 80;
    server_name example.com;

    location / {
        proxy_pass http://app_backend;
        proxy_set_header Host              $host;
        proxy_set_header X-Real-IP         $remote_addr;
        proxy_set_header X-Forwarded-For   $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_next_upstream error timeout http_502 http_503;   # retry on another server
    }
}

max_fails=3 fail_timeout=30s is the passive check: 3 failures within 30 seconds and that server is skipped for 30 seconds. ip_hash; instead of least_conn; gives IP stickiness, but can't be combined with backup.

$ sudo nginx -t                  # syntax check first
$ sudo systemctl reload nginx    # apply without dropping connections

CDNs and Cache-Control

A CDN is a worldwide network of reverse proxies (edge servers). Users hit the nearest one; on a hit it answers from cache, on a miss it fetches from your origin and keeps a copy. Faster pages far away, less load on the origin, and a big front door that absorbs DDoS attacks. The origin controls caching with Cache-Control:

Header valueMeaning / use
public, max-age=31536000, immutableCache for a year, never changes. For fingerprinted files like app.3f9a1c.js.
public, max-age=60, s-maxage=600Browsers 1 minute, shared caches (CDNs) 10 minutes.
no-cacheMay be stored, but must be revalidated before each use. HTML that must be current.
no-storeNever store anywhere. Sensitive pages.
privateBrowser only, never a CDN. Logged-in, personalised pages.

Despite the name, no-cache doesn't mean "don't cache"; no-store does. Revalidation uses ETag: the server answers 304 Not Modified with no body if nothing changed. Age shows how long a response has sat in a cache.

Cloudflare as an example

Mark a DNS record proxied (orange cloud) and DNS returns Cloudflare's IPs, so every request passes their edge: TLS terminated, cache and firewall rules applied, then forwarded to your origin. By default it caches static files by extension, but not HTML unless you add a Cache Rule. Purge the cache after a deploy if needed.

$ curl -sI https://example.com/logo.png | grep -iE 'server|cf-cache-status|cache-control|age'
server: cloudflare
cf-cache-status: HIT             # or MISS, EXPIRED, BYPASS, DYNAMIC (not cacheable)
cache-control: public, max-age=14400
age: 812

The SSL/TLS mode sets how Cloudflare reaches your origin: Flexible uses plain HTTP (the second half of the trip is unencrypted), Full uses HTTPS with any certificate, Full (strict) requires a valid one. Aim for Full (strict).

How one request travels

Browser ── DNS: example.com → Cloudflare edge IP
  ▼
CDN edge         TLS #1 ends here; cache HIT answers immediately
  ▼  (miss)      adds CF-Connecting-IP / X-Forwarded-For
Load balancer    TLS #2 ends here; picks a healthy target
  ▼
Reverse proxy    routes /api to the API, / to the frontend
  ▼
App              reads the real client IP from forwarded headers

Errors and what they point to

  • 502 Bad Gateway: the proxy got no valid response from the backend: app down, crashed, wrong port, or listening only on 127.0.0.1. Nginx's error log will show "connect() failed (111: Connection refused)".
  • 504 Gateway Timeout: the backend answered too slowly. Find the slow query, or raise proxy_read_timeout if it's expected.
  • AWS targets "unhealthy": the health check isn't getting a 200: wrong path, a redirect, or a security group blocking the load balancer.
  • Cloudflare 521 origin refused the connection, 522 timed out (often a firewall), 525 TLS handshake with origin failed, 526 invalid origin certificate in Full (strict).
  • ERR_TOO_MANY_REDIRECTS behind Cloudflare: Flexible mode sends HTTP, the origin redirects to HTTPS, repeat forever. Use Full (strict).
  • Every log line shows the same client IP: the app sees the proxy. Use X-Forwarded-For, trusting it only from your own proxies.
  • Old version still showing after a deploy: a stale cache. Purge the CDN, and use fingerprinted file names.

Questions

Pick an answer. Get it wrong and you can try again right away, no waiting. 10 questions per topic - pick a filter below, then use Recreate questions for a fresh set on that topic.

Fresh questions every time

Exam

A mixed test across the whole site, shuffled so you never know which topic comes next. When you submit, every mistake comes with the reason and a jump to the exact moment in the video that explains it.

30 questions 6 topics 20 minute limit Up to 70 XP
1–4 answer · ←→ move
History

Essay

0 / 200-250 words
Sample answer
History
0:00 / 0:00
Not started

on YouTube
Subscribe

Topic progress

Activity

Achievements

Settings

Your profile and your account.

Profile details

* Required. Saved in this browser until you sign in.

Letters, numbers, dots, dashes and underscores.
0 / 160

Account

Checking…

App

Install Stackwise on your phone or computer. It opens in its own window from your home screen, and the Docs and cheat sheets you've opened keep working without internet.

Only admins can see this

Dashboard

Sign-ups, activity, messages and reviews in one place.

Prove it

Certificates

Pass a topic's test and get a certificate with its own public page you can share or add to LinkedIn. Each test is 10 questions drawn at random and graded on the server; you need 8 right, you have 15 minutes, and you get one try per topic a day.

From first command to production

Linux for DevOps

A path through Linux the way DevOps engineers use it: ten stages, every command explained with its flags, examples, real output and mistakes, the combinations engineers chain together, and incidents worked through step by step. Practise everything in a safe lab folder.

Before the interview

Interview prep

Questions that come up in real DevOps interviews, with the kind of answer that lands. Say yours out loud first, then compare. Each one links to the chapter that goes deeper.

    Private to you

    My notes

    Everything you wrote down while watching and reading, in one place. Saved to your account, never shown to anyone.