Bash終端命令列,使用privoxy將socks代理轉成http代理
阿新 • • 發佈:2019-01-29
安裝privoxy
# Ubuntu/debian
sudo apt-get install privoxy
# Centos
sudo yum install privoxy
# Mac osx
sudo port install privoxy
修改配置檔案
vi /etc/privoxy/config # HTTP parent looks like this: # forward-socks4 / 127.0.0.1:1080 . # # To chain Privoxy and Tor, both running on the same system, you # would use something like: # forward-socks5 / 127.0.0.1:1080 .
主要是forward-socks 這兩行,1080是socks代理開啟的埠,根據自己實際情況修改
配置完成後,重啟privoxy,sudo service privoxy restart
新增代理開關函式
vi ~/.bashrc,新增如下程式碼:
function proxy_off(){ unset http_proxy unset https_proxy unset ftp_proxy unset rsync_proxy echo -e "已關閉代理" } function proxy_on() { export no_proxy="localhost,127.0.0.1,localaddress,.localdomain.com" export http_proxy="http://127.0.0.1:8118" export https_proxy=$http_proxy export ftp_proxy=$http_proxy export rsync_proxy=$http_proxy export HTTP_PROXY=$http_proxy export HTTPS_PROXY=$http_proxy export FTP_PROXY=$http_proxy export RSYNC_PROXY=$http_proxy echo -e "已開啟代理" }
使用的時候,需要開啟http代理時,就在命令列輸入:proxy_on
此種情況多數用於命令列需要連結的伺服器,被牆需要扶梯子時,比如下載android原始碼,chromium原始碼 …