Security & infrastructure
Once an app is on the internet you have to control who can reach it, keep private parts private, and spread traffic across several servers. The same building blocks appear in every data centre and every cloud; the cloud just gives them different names.
Firewalls
A firewall allows or blocks traffic by rules: source address, destination port, protocol. The safe default is "deny everything inbound, then allow only what's needed", for example ports 22, 80 and 443 on a web server. Modern firewalls are stateful: once they allow an outgoing request, they automatically let its reply back in. On a Linux server that's ufw; in the cloud it's security groups.
NAT
Network address translation rewrites addresses as traffic passes through a router. Its main job is letting many machines with private IPs share one public IP to reach the internet. A useful side effect: machines behind NAT can start connections outward, but nobody on the internet can start a connection to them. That's why NAT is used for servers that need to download updates but shouldn't be reachable.
203.0.113.7. Replies to connections you started come back in; new connections from outside have nowhere to go.VPN
A VPN builds an encrypted tunnel across the public internet so a remote laptop (or a whole office) behaves as if it were inside the private network. Companies use VPNs to reach internal servers without exposing them to the internet.
Load balancers and reverse proxies
A load balancer sits in front of several identical servers and spreads incoming requests across them. It checks each server's health and stops sending traffic to one that fails, so the site stays up while a server is replaced. Layer 4 load balancers route by IP and port only; layer 7 ones understand HTTP and can route by URL path or hostname (/api to one group of servers, / to another).
A reverse proxy such as Nginx is the same idea at a smaller scale: it receives requests for the backend app, forwards them, and often handles HTTPS, compression and caching on the way. A CDN (Cloudflare, CloudFront) puts cached copies of your site on servers all over the world, so users download from somewhere close to them.
Cloud networking: the VPC
In AWS (and similarly in Azure and GCP) your servers live inside a VPC, a Virtual Private Cloud: your own isolated private network, for example 10.0.0.0/16, that no one else's traffic can enter. You divide it into subnets and decide how each one reaches the outside:
- Public subnet: has a route to an internet gateway, so its machines can have public IPs and be reached from the internet. Load balancers and web servers go here.
- Private subnet: no route from the internet. Databases and internal services go here. If they need to download updates, they go out through a NAT gateway in a public subnet.
- Route tables decide where traffic from each subnet goes: stay in the VPC, to the internet gateway, or to the NAT gateway.
- Security groups are firewalls around each instance: "this database only accepts port 5432 from the web servers' security group". They're stateful. Network ACLs are an extra, stateless filter on a whole subnet.
Internet
│
Internet gateway
│
Public subnet 10.0.1.0/24 ── load balancer, web servers ── NAT gateway
│ │
Private subnet 10.0.2.0/24 ── app servers, database ──(outbound only)
A server's network card inside the machine usually shows up as eth0; ip a lists interfaces and their addresses, and ip route shows where traffic is sent.