Use proxy in linux
0x01 Make it work
wget https://bootstrap.pypa.io/get-pip.py && python get-pip.py
pip install shadowsocks
sslocal -s your-ss-ip -p 443 -k "your-ss-code" -l 1080 -m aes-256-cfb --user nobody -d start
curl --socks5 127.0.0.1:1080 ip.cn
yum -y install privoxy
service privoxy start
cp /etc/privoxy/config /etc/privoxy/config_bak
vim /etc/privoxy/config
ensure below lines are not commented, line1 usually not, line2 need modifylisten-address 127.0.0.1:8118 forward-socks5t / 127.0.0.1:1080 .
- run below in bash
export http_proxy=http://127.0.0.1:8118 export https_proxy=http://127.0.0.1:8118
chkconfig privoxy on && service privoxy start
curl ipinfo.io
0x02 Be elegant
- CentOS install
yum -y install privoxy pip -y pip install shadowsocks cp /etc/privoxy/config /etc/privoxy/config_bak
Ubuntu install
sudo apt install python-pip git privoxy -y pip install -U git+https://github.com/shadowsocks/shadowsocks.git@master cp /etc/privoxy/config /etc/privoxy/config_bak
vim /etc/privoxy/config
uncomment below lineforward-socks5t / 127.0.0.1:9050 .
- save below code to a file like
setproxy
, then. setproxy on
means open,. setproxy off
means shutdown#!/bin/bash ip=1.1.1.1 port=11111 key=123456 if [ "$1" == "on" ]; then sslocal -s $ip -p $port -k $key -l 9050 -m aes-256-cfb --user nobody -d start service privoxy start export http_proxy=http://127.0.0.1:8118 export https_proxy=http://127.0.0.1:8118 elif [ "$1" == "off" ]; then sslocal -s $ip -d stop service privoxy stop export http_proxy="" export https_proxy="" elif [ "$1" == "status" ]; then service privoxy status elif [ "$1" == "log" ]; then tail -f /var/log/shadowsocks.log elif [ "$1" == "test" ]; then sslocal -s $ip -p $port -k $key -l 9050 -m aes-256-cfb else echo 'Please input argument: on,off,status' fi echo 'Now your ip is: ' curl ipinfo.io echo ''
0x03 Another host comes
An image that the stream flow:
- Listen: ss-server[socks 1080] –> privoxy(forward-socks5t[socks 1080]>listen-address[http,https 8118])
- Request: application, like curl –> localhost[http,https 8118]
Now comes another machine: C (A is ss-server, B is ss-client configured as 0x02), let C join the play:
- on B, change
listen-address 127.0.0.1:8118
tolisten-address 0.0.0.0:8118
in/etc/privoxy/config
- on C, run
export http_proxy=http://127.0.0.1:8118; export https_proxy=http://127.0.0.1:8118
, or make aproxy_switch.sh
:#!/bin/bash if [ "$1" == "on" ]; then export http_proxy=http://B_ip:8118 export https_proxy=http://B_ip:8118 echo 'http and https proxy has set to B_ip:8118' curl ipinfo.io elif [ "$1" == "off" ]; then export http_proxy="" export https_proxy="" echo 'http and https proxy OFF' else echo 'http_proxy:' echo $http_proxy echo 'https_proxy' echo $https_proxy echo 'Please input argument: on,off' fi
- run
. proxy_swtich.sh on
to enjoy C ~