Proxy Cheat Sheet
§1. SOCKS over SSH
Open a SOCKS proxy on your local port 8080 over a standard SSH connection:
1 | ssh -D 8080 -N name@ip -p 22 |
Then, configure some local apps (like Firefox and Homebrew) to use this SOCKS proxy.
§Firefox
To configure Firefox:
- Use a manual SOCKS5 proxy at
127.0.0.1:8080
. - Note: You may need to disable any Firefox VPN extensions for this to work.
§Homebrew
Set the following environment variable to use the proxy:
1 | export ALL_PROXY=socks5://127.0.0.1:8080 |
§2. Shadowsocks
§Server Setup
Download the appropriate version from the Shadowsocks GitHub repository:
https://github.com/shadowsocks/shadowsocks-rust/releases For example,
shadowsocks-v1.20.4.x86_64-unknown-linux-gnu.tar.xz
for Debian AMD64.
Create a config.json
file:
1 | { |
Run the Shadowsocks server:
1 | ./ssserver -c config.json |
§Client: ShadowsocksX-NG on Mac
In Firefox, set it to use system proxy settings:
- Go to Firefox > Preferences > Network Settings > Use system proxy settings.
However, you may encounter this bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1700857
To resolve it:
- Set a SOCKS5 proxy in System Preferences.
- Select “Use system proxy settings” in Firefox.
- Change
network.proxy.default_pac_script_socks_version
:- Set it to 4 = Doesn’t work.
- Set it to 5 = Works.
§Related: Launch VPN on a Remote Server Without Interrupting the Current SSH Session
To prevent SSH from disconnecting after connecting to a VPN on the remote server, run:
1 | ip route show |
- Client IP:
27.196.119.86
- Default gateway:
192.168.1.1
Then add a route:
1 | sudo ip route add 27.196.119.86 via 192.168.1.1 |
For more details, check this link: https://serverfault.com/questions/649792/prevent-ssh-connection-lost-after-logging-into-vpn-on-server-machine