Forward Proxy & Reverse Proxy

Featured Image

Forward Proxy

An intermediary that handles client requests to servers. Key features:
– Access Control & Filtering: Blocks malicious sites or restricts access.
– Anonymity: Masks client IP addresses.
– Caching: Stores frequently accessed data for faster retrieval.
– Bandwidth Optimization: Reduces data usage via compression.
– Logging: Tracks user activity for security audits.

Reverse Proxy

Acts as a gateway for servers, managing incoming client requests. Key features:
– Load Balancing: Distributes traffic across backend servers.
– SSL Termination: Decrypts HTTPS traffic to reduce server load.
– Security Layer: Protects against DDoS, SQLi, and XSS attacks.
– Web Acceleration: Caches static content for faster delivery.
– Authentication: Enforces access controls before routing requests.

You Should Know: Practical Implementation

  1. Setting Up a Forward Proxy with Squid (Linux)
    Install Squid 
    sudo apt update && sudo apt install squid -y
    
    Configure Squid (edit /etc/squid/squid.conf) 
    http_port 3128 
    acl allowed_ips src 192.168.1.0/24 
    http_access allow allowed_ips 
    cache_dir ufs /var/spool/squid 1000 16 256
    
    Start & enable Squid 
    sudo systemctl start squid 
    sudo systemctl enable squid 
    

2. Configuring a Reverse Proxy with Nginx

 Install Nginx 
sudo apt install nginx -y

Configure reverse proxy (edit /etc/nginx/sites-available/default) 
server { 
listen 80; 
server_name example.com;

location / { 
proxy_pass http://backend_servers; 
proxy_set_header Host $host; 
proxy_set_header X-Real-IP $remote_addr; 
} 
}

Test & reload Nginx 
sudo nginx -t 
sudo systemctl reload nginx 

3. Enabling SSL Termination

 Obtain SSL Cert via Certbot 
sudo apt install certbot python3-certbot-nginx -y 
sudo certbot --nginx -d example.com

Auto-renew SSL 
sudo certbot renew --dry-run 

4. Load Balancing with HAProxy

 Install HAProxy 
sudo apt install haproxy -y

Configure (edit /etc/haproxy/haproxy.cfg) 
frontend http_front 
bind :80 
default_backend http_back

backend http_back 
balance roundrobin 
server server1 192.168.1.10:80 check 
server server2 192.168.1.11:80 check

Restart HAProxy 
sudo systemctl restart haproxy 

5. Security Hardening

 Block SQLi/XSS in Nginx 
location / { 
proxy_pass http://backend; 
proxy_set_header X-Forwarded-For $remote_addr; 
proxy_set_header X-Real-IP $remote_addr; 
proxy_set_header Host $host; 
proxy_intercept_errors on; 
proxy_redirect off; 
proxy_hide_header X-Powered-By; 
} 

What Undercode Say

Proxies are essential for security, performance, and anonymity. Forward proxies protect clients, while reverse proxies safeguard servers. Implementing them with Squid, Nginx, or HAProxy ensures optimized traffic flow, encrypted communications, and attack mitigation.

Key Commands Recap:

  • Squid Proxy: `sudo squid -k reconfigure` (reload config)
  • Nginx Reverse Proxy: `sudo nginx -T` (debug config)
  • HAProxy Stats: `echo “show stat” | sudo socat stdio /run/haproxy/admin.sock`
  • SSL Check: `openssl s_client -connect example.com:443`
  • Traffic Logs: `tail -f /var/log/nginx/access.log`

Expected Output:

A fully configured proxy setup enhancing security, speed, and reliability for enterprise or personal use.

Further Reading:

References:

Reported By: Satya619 %F0%9D%91%AD%F0%9D%92%90%F0%9D%92%93%F0%9D%92%98%F0%9D%92%82%F0%9D%92%93%F0%9D%92%85 – Hackers Feeds
Extra Hub: Undercode MoN
Basic Verification: Pass ✅

Join Our Cyber World:

💬 Whatsapp | 💬 Telegram