Library / Blogs

Nordic APIs Engineering Blog

Learn how to make smarter tech decisions using APIs. The number one resource for API practitioners containing API insights.

By Nordic APIs engineers · Nordic APIs · Added 2026-10-12

Open original source

All content belongs to Nordic APIs engineers / Nordic APIs. We only link to it and give credit. Report a problem

Learn this article

About 37 min left. Your work is saved as you go.

What you are about to study

Nordic APIs wrote this to explain how they thought about a problem. You should know the basics: caching, queues and replication.

Ideas you will meet

Distributed Systems
Consensus, time, failure and the fundamentals of scale-out.

What we already know about this

Our own lessons on these ideas. Read them here before you start, so it makes sense.

  • Networking and Web Security Deep Dive · 12 minProxies, NAT, VPNs and firewallsThe network middlemen: what forward and reverse proxies do, how NAT shares addresses, what a VPN protects and how firewalls decide what passes.Read here

    Why middlemen exist

    Between a client and a server there are often several intermediaries. Each solves a different problem: hide, share, protect or control. Knowing which is which keeps architecture diagrams honest.

    Forward proxy (acts for clients)

    A forward proxy sits in front of clients. Clients send requests to it and it fetches from the internet on their behalf.

    • Why: control and log outbound access (company networks), filter content, cache, hide client addresses, bypass regional limits.
    • Who knows what: the server sees the proxy, not the client.
    • Example: a company proxy that only allows approved sites; an egress proxy that lets servers call only listed external APIs.

    Reverse proxy (acts for servers)

    A reverse proxy sits in front of servers. Clients think they talk to the site; the proxy forwards to the right backend.

    • Why: TLS termination, load balancing, caching and compression, routing by host or path, hiding the internal layout, absorbing attacks and slow clients, adding headers.
    • Examples: NGINX, HAProxy, Envoy, cloud load balancers, CDNs (a CDN is a reverse proxy network).
    • An API gateway is a reverse proxy with API-specific policy (see the load balancing lesson).

    Figure SDA-NSD-02-1 · Forward and reverse proxies · © forcsguy.com

    Before: forward proxy

    After: reverse proxy

    What changed

    • A forward proxy acts for the clients, a reverse proxy acts for the servers
    • A reverse proxy hides and protects the backend
    • Both sit in the middle but face opposite ways

    NAT: sharing addresses

    IPv4 addresses are scarce. Network Address Translation (NAT) lets many devices with private addresses (10.x.x.x, 172.16-31.x.x, 192.168.x.x) share one public address. The NAT device rewrites the source address and port of outgoing packets and remembers the mapping to send replies back to the right device.

    • Side effect: devices behind NAT are not directly reachable from outside, which is a mild protection but not a firewall.
    • In the cloud, a NAT gateway lets private servers reach the internet (for updates and APIs) without being reachable from it.
    • NAT complicates peer-to-peer connections (hence STUN, TURN and ICE in video calls; see the real-time communication lesson).
    • IPv6 has enough addresses that NAT is not needed for scarcity.

    VPN: a private tunnel

    A virtual private network creates an encrypted tunnel across an untrusted network.

    • Remote access: staff connect to the company network from anywhere.
    • Site to site: two networks (office and cloud) are joined securely.
    • Privacy services: traffic is routed via a provider's server.
    • It protects traffic in transit between the endpoints; it does not make the endpoints themselves safe. Modern designs increasingly favour zero trust: authenticate every request to every service, rather than trusting "inside the network".

    Firewalls: allow or deny

    A firewall filters traffic by rules.

    • Packet filter / stateless: allow or deny by source and destination IP, port and protocol.
    • Stateful: remembers connections, so replies to allowed outbound traffic are allowed automatically.
    • Application-layer / WAF: understands HTTP and blocks known attack patterns (for example SQL injection attempts).
    • In the cloud: security groups (attached to instances, stateful) and network ACLs (on subnets, often stateless).

    Figure SDA-NSD-02-2 · Layered network defence for a web app · © forcsguy.com

    Principles: default deny, least privilege (open only needed ports to only needed sources), segment (separate tiers and environments), and log. A rule that says "allow all from anywhere" on a database port is a classic breach.

    Putting it together

    DeviceSits in front ofMain purpose
    Forward proxyClientsControl and anonymise outbound traffic
    Reverse proxy / load balancerServersRoute, protect, terminate TLS
    NATA private networkShare addresses, hide internals
    VPNTwo endpoints or networksEncrypted tunnel over untrusted links
    FirewallA network or hostAllow or deny traffic by rules

    Common mistakes

    Treating NAT or a VPN as sufficient security; databases reachable from the internet; no outbound restrictions (a compromised server can call anywhere); admin tools exposed publicly; and forgetting that a TLS-terminating proxy sees plain text and must itself be protected.

    Real-world reading

    Open this lesson with its quiz and exercise

Go deeper on this

A path through videos, articles, other case studies and code on the same ideas as Nordic APIs Engineering Blog.

  1. Warm upGet the vocabulary first.

  2. WatchHow others solve the same problem, on video.

    Videos belong to their creators and play from YouTube. More on YouTube (opens in a new tab)

  3. ReadEngineers explain it in their own words.

  4. See it in another companyThe same ideas, a different system.

  5. Read the codeSee how it looks when it is real.

Keep learning

Loading community…