#Reverse Proxy
A reverse proxy sits in front of web servers.
#Use Cases
- Load Balancing: Distribute traffic
- SSL Termination: Handle TLS
- Caching: Cache static content
- Security: Hide server details
#Architecture
[Internet] → [Reverse Proxy] → [Web Servers]
#Nginx Reverse Proxy
nginx
1# /etc/nginx/sites-available/app
2upstream backend {
3 server 127.0.0.1:3000;
4 server 127.0.0.1:3001;
5}
6
7server {
8 listen 80;
9 server_name example.com;
10
11 location / {
12 proxy_pass http://backend;
13 proxy_set_header Host $host;
14 proxy_set_header X-Real-IP $remote_addr;
15 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
16 }
17}#Popular Reverse Proxies
| Tool | Strengths |
|---|---|
| Nginx | High performance, widely used |
| HAProxy | Advanced load balancing |
| Traefik | Cloud native, auto-discovery |
| Caddy | Automatic HTTPS |
[!TIP] Pro Tip: Always set proper headers (X-Real-IP, X-Forwarded-For) when proxying!