Skip to content

lee-jason/socksproxy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

SSH Proxy Server on AWS EC2

This project sets up a minimal EC2 instance for SSH tunneling/SOCKS proxy on AWS using Terraform.

Quick Start

1. Prerequisites

  • AWS CLI configured with credentials
  • Terraform installed
  • SSH key pair created locally (ssh-keygen -t rsa)

2. Configure Variables

# Copy and configure variables
cp terraform.tfvars.example terraform.tfvars
# Edit terraform.tfvars with your values

3. Deploy Infrastructure

# Initialize Terraform
terraform init

# Review the deployment plan
terraform plan

# Deploy the infrastructure
terraform apply

4. Create SSH Tunnel

# Get the server IP from Terraform output
SERVER_IP=$(terraform output -raw proxy_server_public_ip)

# Create SOCKS proxy on port 8080
ssh -D 8080 -N ubuntu@$SERVER_IP

5. Configure Your Browser

Configure your browser to use localhost:8080 as a SOCKS5 proxy:

Chrome/Chromium:

# Launch Chrome with proxy
google-chrome --proxy-server="socks5://localhost:8080"

Firefox:

  • Settings > Network Settings > Manual proxy configuration
  • SOCKS Host: localhost, Port: 8080, SOCKS v5

Safari:

  • System Preferences > Network > Advanced > Proxies
  • Check "SOCKS Proxy", enter localhost:8080

Files

  • main.tf - Terraform infrastructure configuration
  • terraform.tfvars.example - Example Terraform variables

Usage

Start SSH Tunnel

# Get server IP
SERVER_IP=$(terraform output -raw proxy_server_public_ip)

# Start tunnel (runs in foreground)
ssh -D 8080 -N ubuntu@$SERVER_IP

# Or run in background
ssh -D 8080 -N -f ubuntu@$SERVER_IP

Test Your Proxy

# Check your IP without proxy
curl ifconfig.me

# Check your IP through proxy
curl --socks5 localhost:8080 ifconfig.me

Stop Background Tunnel

# Find the SSH process
ps aux | grep "ssh -D 8080"

# Kill the process
kill <PID>

Use with curl/wget

# Use proxy with curl
curl --socks5 localhost:8080 https://example.com

# Use proxy with wget
wget -e use_proxy=yes -e https_proxy=socks5://localhost:8080 https://example.com

What This Gives You

  • Your real IP: Your home/office IP address
  • Proxy IP: Your EC2 instance IP in US West
  • Websites see: EC2 instance location (US West)
  • Traffic encrypted: Between you and EC2 instance
  • Bypasses: Geographic restrictions, some firewalls

Cleanup

terraform destroy

Security Notes

  • Change allowed_ssh_cidr in terraform.tfvars to restrict SSH access to your IP
  • The server only allows SSH (port 22) - no additional ports opened
  • All proxy traffic goes through encrypted SSH tunnel

Costs

  • t3.micro instance: ~$8.50/month (free tier eligible for 12 months)
  • Data transfer: $0.09/GB for first 100GB/month
  • Total for light usage: ~$10-15/month

Troubleshooting

Can't connect to server

# Test SSH connection
ssh ubuntu@$(terraform output -raw proxy_server_public_ip)

Tunnel not working

# Check if tunnel is running
ps aux | grep "ssh -D"

# Test proxy connection
curl --socks5 localhost:8080 ifconfig.me

Wrong IP showing

  • Make sure your browser/app is configured to use the SOCKS5 proxy
  • Check proxy settings: localhost:8080, protocol: SOCKS5

About

Spin up a lightweight socks proxy

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages