Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proxify all instances through themselves #707

Open
gwen001 opened this issue Apr 25, 2023 · 0 comments
Open

Proxify all instances through themselves #707

gwen001 opened this issue Apr 25, 2023 · 0 comments

Comments

@gwen001
Copy link

gwen001 commented Apr 25, 2023

Don't know if anyone would find this interesting but I tried and it works pretty well !
To avoid errors I also manually opened the port 8080 in the security group rules.

1/ get fleet ips
axiom-ls | ansi2txt | awk '{print $2}' | egrep "^[0-9]{1,3}\." | sort > fleet-ips

2/ upload the ips list on all instances
axiom-scp fleet-ips '\*':~/

3/ upload the magic script below on all instances
axiom-scp fleet-proxies.sh '\*':~/

4/ upload the ssh key on all instances
axiom-scp ~/.ssh/axiom_rsa '\*':~/.ssh/

5/ run the magic script on all instances
axiom-exec '~/fleet-proxies.sh'

6/ connect on a single instance using axiom-ssh ...

7/ check the ip changing at every request
curl -s -x socks5h://127.0.0.1:1337 https://ipinfo.io


The magic script fleet-proxies.sh (don't forget to chmod +x it !)
I used the code from the original axiom-proxy.

#!/bin/bash

sudo apt-get -yq install haproxy

eval $(ssh-agent)
ssh-add ~/.ssh/axiom_rsa

echo -e "global\n\t\tdaemon\n\t\tuser root\n\t\tgroup root\n\ndefaults\n\t\tmode tcp\n\t\tmaxconn 3000\n\t\ttimeout connect 5000ms\n\t\ttimeout client 50000ms\n\t\ttimeout server 50000ms\n\nlisten funnel_proxy\n\t\tbind *:1337\n\t\tmode tcp\n\t\tbalance roundrobin\n\t\tdefault_backend doxycannon\n\nbackend doxycannon" >> "haproxy.cfg"

i=0

cat "fleet-ips" | while read ip ; do
    i=$((i+1))
    append=$(printf "%02d" "$i")
    port="50$append"
    ssh-keygen -R "[$ip]:2266" >>  /dev/null 2>&1
    ssh -p2266 -o StrictHostKeyChecking=no -D $port op@$ip -R 8080:127.0.0.1:8080 -N 2>&1 >>/dev/null &
    echo -e "\tserver $ip 127.0.0.1:$port" >> haproxy.cfg
done

sudo cp /etc/haproxy/haproxy.cfg /etc/haproxy/haproxy.cfg.bak
sudo cp haproxy.cfg /etc/haproxy/haproxy.cfg
sudo /etc/init.d/haproxy restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant