In this series: DevOps
  1. 1 What is an API Gateway? Single Entry Point for Microservices
  2. 2 What is NAT? Network Address Translation Explained
  3. 3 What is GitLab CI/CD? Automated Pipeline for Build, Test, and Deploy
  4. 4 What is Apache Kafka? Distributed Event Streaming Platform Explained
  5. 5 What is Serverless? FaaS, Cold Start, and When to Go Serverless
  6. 6 What is Subnet & CIDR? IP Network Segmentation and Routing
  7. 7 What is Kubernetes? The Most Popular Container Orchestration Platform Today
  8. 8 What is a Proxy? Forward Proxy, Reverse Proxy and SOCKS5 Explained
  9. 9 What is Nginx? Web server, reverse proxy, and load balancer in one
✦ Quick summary
A proxy server is an intermediary between client and server. Learn the differences between Forward Proxy, Reverse Proxy, and SOCKS5 with real configuration examples for Squid and NGINX.
How was this post?

Proxy is one of those networking concepts that appears everywhere yet is often misunderstood. Forward proxy, reverse proxy, SOCKS5 — each type serves a different purpose. This article clearly explains each one with real-world configuration examples.

What is a Proxy?

A proxy server is an intermediary server that acts on behalf of either a client or a server during network communication. Instead of the client connecting directly to the destination server, all traffic passes through the proxy.

Benefits of using a proxy:

  • Anonymity: Hides the real IP address of the client or server
  • Caching: Stores responses to serve repeated requests faster (without fetching from the origin)
  • Access control: Blocks or allows traffic based on policy
  • Load balancing: Distributes traffic across multiple backend servers
  • SSL termination: Handles TLS at the proxy level so backends can use plain HTTP

There are three main types of proxy: Forward Proxy, Reverse Proxy, and SOCKS5 Proxy.

Forward Proxy

A Forward Proxy sits between the client and the internet. The client knows it is using a proxy and must configure it explicitly (in the browser, OS, or application).

Traffic flow:

Client → Forward Proxy → Internet → Destination Server

The destination server sees the proxy's IP, not the client's real IP.

Common use cases:

  • Corporate web filtering: IT departments block inappropriate websites (social media, games) and log web access
  • Bypassing geo-restrictions: A client in Vietnam uses a US-based proxy to access content restricted to the US
  • Development and debugging: Dev teams use proxies to intercept and inspect HTTP requests (Charles Proxy, mitmproxy)

Squid Forward Proxy — basic configuration:

Bash
 1# Install Squid
 2apt-get install squid
 3
 4# /etc/squid/squid.conf
 5http_port 3128
 6
 7# Allow internal network
 8acl localnet src 192.168.0.0/16
 9acl localnet src 10.0.0.0/8
10http_access allow localnet
11
12# Block social media
13acl social dstdomain .facebook.com .tiktok.com .youtube.com
14http_access deny social
15
16# Deny all other traffic
17http_access deny all
Bash
1# Test the proxy from a client
2curl -x http://proxy-server:3128 https://httpbin.org/ip
3# The response will return the proxy's IP, not the client's
4
5# Set proxy for the entire terminal session
6export http_proxy="http://proxy-server:3128"
7export https_proxy="http://proxy-server:3128"

Reverse Proxy

A Reverse Proxy sits in front of backend servers. The client (browser) does not know the proxy exists — they think they are connecting directly to the real server. The backend IP addresses are completely hidden from the client.

Traffic flow:

Client → Reverse Proxy → Backend Server 1
                       → Backend Server 2
                       → Backend Server 3

NGINX as a Reverse Proxy:

nginx
 1# /etc/nginx/sites-available/myapp
 2server {
 3    listen 80;
 4    server_name api.example.com;
 5
 6    location / {
 7        proxy_pass http://localhost:3000;
 8        proxy_set_header Host $host;
 9        proxy_set_header X-Real-IP $remote_addr;
10        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
11        proxy_set_header X-Forwarded-Proto $scheme;
12    }
13}
14
15# Load balancing with upstream
16upstream backend_pool {
17    server 10.0.1.10:3000 weight=3;
18    server 10.0.1.11:3000 weight=1;
19    server 10.0.1.12:3000 backup;
20}
21
22server {
23    listen 443 ssl;
24    server_name api.example.com;
25
26    location /api/ {
27        proxy_pass http://backend_pool;
28    }
29}

Common use cases for a Reverse Proxy:

  • SSL termination: NGINX handles TLS; backends only need plain HTTP
  • Load balancing: Distributes requests across multiple instances
  • Static file serving: NGINX serves static assets; backends focus on business logic
  • Rate limiting: Limits requests from a single IP address
  • Security: Hides backend information (versions, IPs, ports)

SOCKS5 Proxy

SOCKS5 is a proxy that operates at the session layer (OSI Layer 5) and is independent of the application protocol. It tunnels any TCP/UDP traffic — HTTP, SMTP, FTP, SSH, game traffic, and more.

Creating a SOCKS5 proxy via SSH tunnel:

Bash
 1# Create an SSH SOCKS5 tunnel (port 1080 on localhost)
 2ssh -D 1080 -N -f user@jumphost.example.com
 3# -D 1080: create a SOCKS5 proxy on port 1080
 4# -N: do not execute a remote command
 5# -f: run in the background
 6
 7# Test via SOCKS5
 8curl --socks5 127.0.0.1:1080 https://httpbin.org/ip
 9curl --socks5-hostname 127.0.0.1:1080 https://ifconfig.me
10
11# Use with git (proxy git pull through the SSH tunnel)
12git config --global http.proxy socks5://127.0.0.1:1080

Configuring SOCKS5 in Python (requests library):

Python
1import requests
2
3proxies = {
4    "http": "socks5://127.0.0.1:1080",
5    "https": "socks5://127.0.0.1:1080",
6}
7
8response = requests.get("https://httpbin.org/ip", proxies=proxies)
9print(response.json())  # Returns the proxy's IP, not the real IP

SOCKS5 vs HTTP Proxy:

Criteria HTTP Proxy SOCKS5
Protocol HTTP/HTTPS only Any TCP/UDP
Layer Application (L7) Session (L5)
Authentication Basic auth header Username/password
UDP support No Yes
Used for Web browsing Gaming, torrenting, SSH

Proxy vs VPN

Both proxies and VPNs hide your real IP and route traffic through an intermediary server, but they differ significantly in how they work:

Criteria Proxy VPN
Scope One application Entire OS
Encryption Varies (HTTP proxy = none) Always encrypted
DNS App-controlled Routed through VPN (prevents DNS leaks)
Speed Faster Slower (encryption overhead)
Setup Per-app configuration OS-level
Use case Web browsing, dev tools Remote work, full privacy

What is NGINX? Web Server, Reverse Proxy and Load Balancer

What is VPN? Virtual Private Network Explained

What is API Gateway? The Gateway to Microservices

Frequently Asked QuestionsQ&A
What is a proxy server in simple terms?
A proxy server is an intermediary that receives requests from a client, forwards them to the destination server, receives the response, and returns it to the client. The client never connects directly to the destination server — all communication flows through the proxy. Depending on the type, a proxy can hide the client's IP, hide the server's IP, cache content, or control and filter traffic.
What is the difference between a Forward Proxy and a Reverse Proxy?
A Forward Proxy sits on the client side: client → proxy → internet. The client knows it is using a proxy and configures it explicitly. The proxy hides the client's identity from the destination server. Used for: web filtering, bypassing geo-blocks, IP masking. A Reverse Proxy sits on the server side: internet → proxy → backend servers. The client is unaware the proxy exists — they think they are connecting directly to the real server. Used for: load balancing, SSL termination, caching, hiding backend infrastructure.
How is SOCKS5 different from an HTTP proxy?
An HTTP proxy only understands HTTP/HTTPS — it reads and can modify HTTP headers, and only works with web traffic. SOCKS5 operates at the session layer (OSI Layer 5) and is protocol-agnostic: it tunnels any TCP/UDP traffic (HTTP, SMTP, FTP, game traffic, etc.) without reading the content. SOCKS5 supports username/password authentication and UDP relay. It is well-suited for: SSH tunneling, gaming VPNs, and torrenting.
Does a proxy encrypt traffic?
An HTTP proxy does not encrypt — traffic travels in plaintext. The HTTPS CONNECT method creates a tunnel: the client sends a CONNECT request to the proxy, the proxy establishes a TCP tunnel to the server, and then the client performs a TLS handshake end-to-end — the proxy only relays encrypted bytes without reading the content. SOCKS5 also does not encrypt by itself but is often combined with an SSH tunnel to add encryption.
What is the difference between a proxy and a VPN?
A proxy only forwards traffic for a specific application (a browser or app explicitly configured to use it). A VPN creates an encrypted tunnel at the OS level — ALL device traffic goes through the VPN, including DNS. Proxies are generally faster because of less overhead. VPNs are more comprehensive and encrypt everything. A proxy can be bypassed if an app ignores proxy settings. A VPN cannot be bypassed at the application layer.
What is a transparent proxy?
A transparent proxy is one the client is unaware of — no configuration is needed on the client. Traffic is intercepted and redirected to the proxy at the network layer (typically via iptables REDIRECT or TPROXY). ISPs commonly use transparent proxies to cache web content. Enterprises use them to filter web traffic without configuring each device. A transparent proxy does not hide the client's IP.