38 lines
1.1 KiB
Markdown
38 lines
1.1 KiB
Markdown
## Set up port forwarding
|
|
|
|
1. Set up port forwarding
|
|
```bash
|
|
$ ssh -D 8080 -N ubuntu@mercurial-manfifold.eu
|
|
```
|
|
2. Try out connection
|
|
```bash
|
|
$ curl --socks5 127.0.0.1:8080 http://example.com
|
|
```
|
|
|
|
## Set system-wide proxy configuration
|
|
|
|
1. Create `/etc/profile.d/proxy.sh` with the following content:
|
|
```bash
|
|
#!/bin/bash
|
|
|
|
if [ -f "/etc/proxy-enabled" ]; then
|
|
export all_proxy="socks5://127.0.0.1:8080"
|
|
export http_proxy="socks5://127.0.0.1:8080"
|
|
export https_proxy="socks5://127.0.0.1:8080"
|
|
export ftp_proxy="socks5://127.0.0.1:8080"
|
|
export HTTP_PROXY="socks5://127.0.0.1:8080"
|
|
export HTTPS_PROXY="socks5://127.0.0.1:8080"
|
|
export FTP_PROXY="socks5://127.0.0.1:8080"
|
|
export no_proxy="localhost,127.0.0.1,::1"
|
|
export NO_PROXY="localhost,127.0.0.1,::1"
|
|
fi
|
|
```
|
|
2. Add the following to `.zshrc`:
|
|
```bash
|
|
alias proxy-on='sudo touch /etc/proxy-enabled'
|
|
alias proxy-off='sudo rm -f /etc/proxy-enabled'
|
|
```
|
|
|
|
Note that enabling or disabling the proxy only takes effect after logging out
|
|
and back in, as that is when `/etc/profile.d/proxy.sh` is sourced.
|