Skip to content

siutin/n8n-socks5

Repository files navigation

n8n with SOCKS5 Proxy

A Docker Compose setup that runs n8n with all network traffic routed through a SOCKS5 proxy via SSH tunneling. This ensures that all n8n HTTP requests, webhook calls, and external API interactions go through the specified proxy server.

🎯 Purpose

This setup is useful when you need to:

  • Run n8n behind a corporate firewall
  • Access geo-restricted APIs through a proxy
  • Ensure all n8n traffic goes through a specific network path
  • Maintain network isolation and security

🚀 Quick Start

  1. Clone the repository

    git clone https://github.com/siutin/n8n-socks5.git
    cd n8n-socks5
  2. Configure SSH connection

    # Copy your SSH keys to the ssh/ directory
    cp ~/.ssh/your_private_key ssh/id_rsa
    cp ~/.ssh/your_public_key ssh/id_rsa.pub
    
    # Set proper permissions
    chmod 600 ssh/id_rsa
    chmod 644 ssh/id_rsa.pub
  3. Configure connection settings

    # Edit the socks.env file with your SSH server details
    cp socks.env.example socks.env
    nano socks.env
  4. Start the services

    docker-compose up -d
  5. Access n8n

    • Open your browser to http://localhost:5678
    • All n8n traffic will automatically go through the SOCKS proxy

⚙️ Configuration

SSH Connection Settings (socks.env)

SSH_USER=root
SSH_KEY_FILE=id_rsa
SSH_PORT=22
SSH_HOST=your-server-ip

Docker Compose Services

  • socks: Alpine-based SOCKS5 proxy via SSH tunneling
  • n8n: Alpine-based n8n instance with transparent proxying

Ports

  • 5678: n8n web interface
  • 1080: SOCKS5 proxy (for testing)

🧪 Testing

Test SOCKS Proxy

# Test proxy connectivity
curl --socks5 localhost:1080 https://httpbin.org/ip

Test n8n Access

# Check if n8n is accessible
curl http://localhost:5678

Check Container Status

# View running containers
docker-compose ps

# View logs
docker-compose logs -f

📁 File Structure

n8n-socks5/
├── docker-compose.yml      # Main orchestration
├── Dockerfile             # Custom n8n image (Alpine-based)
├── start-socks.sh         # SOCKS proxy startup script
├── start-n8n.sh           # n8n startup script
├── socks.env              # SSH connection configuration
├── socks.env.example      # Configuration template
├── ssh/                   # SSH keys directory
│   ├── id_rsa         # Private key
│   └── id_rsa.pub     # Public key
├── n8n/                   # n8n data directory
└── README.md              # This file

🔍 Troubleshooting

SOCKS Proxy Issues

# Check SOCKS service logs
docker-compose logs socks

# Test SSH connection manually
docker-compose exec socks ssh -i /root/.ssh/id_rsa -p 22 ubuntu@your-server-ip

n8n Issues

# Check n8n service logs
docker-compose logs n8n

# Access n8n container shell
docker-compose exec n8n sh

Network Issues

# Check if proxy is working
docker-compose exec n8n curl --socks5 socks:1080 https://httpbin.org/ip

# Check iptables rules
docker-compose exec n8n iptables -t nat -L

🤝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Test thoroughly
  5. Submit a pull request

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

About

Docker Compose for n8n with all traffic routed through a SOCKS5 proxy

Topics

Resources

Stars

Watchers

Forks