-
-
Save drptbl/8402125a20258310d4da22ba1a76a1f5 to your computer and use it in GitHub Desktop.
Socks proxy to connect private hosts with circleci
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
machine: | |
services: | |
- docker | |
post: | |
- wget https://gist.githubusercontent.com/gianrubio/dce37ee9b9c024937832d776597e2603/raw/4cdb30e5075e8e6064ac48a258e05f518f8c88c0/circleci-tunnel.sh ~/ && chmod +x ~/circleci-tunnel.sh | |
- ~/circleci-tunnel.sh start: | |
background: true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -x | |
set -e | |
function tunnel_up(){ | |
sudo apt-get install redsocks -y | |
ssh -o StrictHostKeyChecking=no -v user@cmyhost -22 -i ~/.ssh/my-private-key -D 9999 -nf "sleep 90000" & | |
echo 'base{log_debug = on; log_info = on; log = "file:/tmp/reddi.log";daemon = on; redirector = iptables;}redsocks { local_ip = 127.0.0.1; local_port = 12345; ip = 127.0.0.1;port = 9999; type = socks5; }' > ~/redsocks.conf | |
sudo redsocks -c ~/redsocks.conf & | |
sudo iptables -t nat -N REDSOCKS | |
sudo iptables -t nat -A REDSOCKS -p tcp -d 10.0.0.0/8 -j DNAT --to 127.0.0.1:12345 | |
sudo iptables -t nat -A OUTPUT -d 10.0.0.0/8 -j REDSOCKS | |
sudo iptables -t nat -I PREROUTING 1 -d 10.0.0.0/8 -j REDSOCKS | |
} | |
if [ $1 == "start" ]; then | |
tunnel_up | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment