一、privoxy简介
Privoxy是一款带过滤功能的代理服务器,针对HTTP、HTTPS协议,经常跟Tor组合使用。通过Privoxy的超级过滤功能,用户从而可以保护隐私、对网页内容进行过滤、管理cookies,以及拦阻各种广告等。
privoxy可以用作单机,也可以应用到多用户的网络,privoxy可以把SOCKS5转换为HTTP代理,也就是俗称的APN。
Privoxy - Home Page
https://www.privoxy.org/
二、安装编译工具和依赖
# yum -y install make gcc
# yum -y intall autoconf
# yum -y install zlib zlib-devel
三、编译安装
https://www.silvester.org.uk/privoxy
# wget https://www.silvester.org.uk/privoxy/Sources/3.0.28%20%28stable%29/privoxy-3.0.28-stable-src.tar.gz
# tar -zxf privoxy-3.0.28-stable-src.tar.gz
# cd privoxy-3.0.28-stable
# autoheader
# autoconf
# ./configure --prefix=/usr/local/privoxy
# make
# useradd privoxy -r -s /usr/sbin/nologin
# make install
查看编译后的生成文件
# ll /usr/local/
# ll /usr/local/privoxy/
# ll /usr/local/privoxy/sbin/
# ll /usr/local/privoxy/etc/
四、配置privoxy
# vim /usr/local/privoxy/etc/config
##############################
listen-address 127.0.0.1:8118
forward-socks5 / 127.0.0.1:1080 .
###############################
四、启动privoxy
方式一
启动privoxy
# /usr/local/privoxy/sbin/privoxy --user privoxy /usr/local/privoxy/etc/config
设置开机自启
# chmod +x /etc/rc.local
# echo "/usr/local/privoxy/sbin/privoxy --user privoxy /usr/local/privoxy/etc/config" >> /etc/rc.local
# echo "exit 0 " >> /etc/rc.local
这种方式比较蠢,不推荐,不符合最佳实践原则。
# ps aux | grep privoxy
# ss -tan | grep 8118
方式二(推荐)
编写privoxy的unit文件
# vim /etc/systemd/system/privoxy.service
######################################################
[Unit]
Description=Privoxy Web Proxy With Advanced Filtering Capabilities
Wants=network-online.target
After=network-online.target
[Service]
Type=forking
PIDFile=/run/privoxy.pid
ExecStart=/usr/local/privoxy/sbin/privoxy --pidfile /run/privoxy.pid --user privoxy /usr/local/privoxy/etc/config
[Install]
WantedBy=multi-user.target
##########################################################
# systemctl daemon-reload
# systemctl enable privoxy
# systemctl start privoxy
# systemctl status privoxy
五、放行相关端口
如果要给局域网内其他机器做代理用,配置文件中 listen-address 设置为 0.0.0.0:8118,需要放行!
# firewall-cmd --permanent --add-port=8118/tcp
# firewall-cmd --reload
六、参考
Types of Proxy HTTP, HTTPS, Socks
https://thesafety.us/http-socks-proxy
CentOS7 安装 privoxy
https://note.xdq.me/centos-7-an-zhuang-privoxy-2
Privoxy (简体中文)
https://wiki.archlinux.org/index.php/Privoxy_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)
Privoxy 教程
https://blog.zfanw.com/privoxy-tutorial
systemd (简体中文)
https://wiki.archlinux.org/index.php/Systemd_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)