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.
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
-
Clone the repository
git clone https://github.com/siutin/n8n-socks5.git cd n8n-socks5 -
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
-
Configure connection settings
# Edit the socks.env file with your SSH server details cp socks.env.example socks.env nano socks.env -
Start the services
docker-compose up -d
-
Access n8n
- Open your browser to
http://localhost:5678 - All n8n traffic will automatically go through the SOCKS proxy
- Open your browser to
SSH_USER=root
SSH_KEY_FILE=id_rsa
SSH_PORT=22
SSH_HOST=your-server-ip- socks: Alpine-based SOCKS5 proxy via SSH tunneling
- n8n: Alpine-based n8n instance with transparent proxying
5678: n8n web interface1080: SOCKS5 proxy (for testing)
# Test proxy connectivity
curl --socks5 localhost:1080 https://httpbin.org/ip# Check if n8n is accessible
curl http://localhost:5678# View running containers
docker-compose ps
# View logs
docker-compose logs -fn8n-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
# 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# Check n8n service logs
docker-compose logs n8n
# Access n8n container shell
docker-compose exec n8n sh# 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- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.