privoxy初体验
背景
在本地搭建一个http代理服务器。
初体验
安装
brew install privoxy
详情
brew info privoxy
privoxy: stable 3.0.28 (bottled)
Advanced filtering web proxy
https://www.privoxy.org/
/usr/local/Cellar/privoxy/3.0.28 (98 files, 2MB) *
Poured from bottle on 2019-11-10 at 20:47:41
From: git://mirrors.ustc.edu.cn/homebrew-core.git/Formula/privoxy.rb
==> Dependencies
Build: autoconf ✔, automake ✔, libtool ✔
Required: pcre ✔
==> Caveats
To have launchd start privoxy now and restart at login:
brew services start privoxy
Or, if you don't want/need a background service you can just run:
privoxy /usr/local/etc/privoxy/config
配置文件
配置文件见:/usr/local/etc/privoxy/config
。
这里仅需要改一下 listen-address
和 forward-socks5t
。这里我是把 listen-address
接收到的http请求,转发到socks5代理 forward-socks5t
后面。
confdir /usr/local/etc/privoxy
logdir /usr/local/var/log/privoxy
actionsfile match-all.action # Actions that are applied to all sites and maybe overruled later on.
actionsfile default.action # Main actions file
actionsfile user.action # User customizations
filterfile default.filter
filterfile user.filter # User customizations
logfile logfile
listen-address 0.0.0.0:8118
toggle 1
enable-remote-toggle 0
enable-remote-http-toggle 0
enable-edit-actions 0
enforce-blocks 0
buffer-limit 4096
enable-proxy-authentication-forwarding 0
forward-socks5t / 127.0.0.1:7167 .
forwarded-connect-retries 0
accept-intercepted-requests 0
allow-cgi-request-crunching 0
split-large-forms 0
keep-alive-timeout 5
tolerate-pipelining 1
socket-timeout 300
前台启动
privoxy /usr/local/etc/privoxy/config
或者
/usr/local/Cellar/privoxy/3.0.28/sbin/privoxy --no-daemon /usr/local/etc/privoxy/config
后台启动
brew services start privoxy
查看日志
tail /usr/local/var/log/privoxy/logfile
测试代理
curl --connect-timeout 2 -x "127.0.0.1:8118" "https://www.baidu.com"
wget -Y on -e "http_proxy=http://127.0.0.1:8118" https://www.baidu.com