这里使用腾讯云的上海地区轻量级服务器搭建,不涉及出墙!
Tinyproxy简介
Tinyproxy 是用于 POSIX 操作系统的轻量级 HTTP/HTTPS 代理守护程序。它从头开始设计,速度快,但体积小,是嵌入式部署等用例的理想解决方案,在这些用例中,需要全功能的 HTTP 代理,但大型代理的系统资源不可用。
安装
Tinyproxy有两种安装方式如下:
git conle <https://github.com/tinyproxy/tinyproxy.git>
./autogen.sh
./configure
make
make install
sudo apt-get install tinyproxy
配置
在安装完成后,需要配置TinyProxy以满足特定需求。首先,编辑配置文件/etc/tinyproxy/tinyproxy.conf
Port 8888 //开放端口
Timeout 600 // 请求超时时长
Allow 127.0.0.1 // 允许连接的IP地址,多个再新增一条,如果完全允许则删除此行
Allow 127.0.0.2
BasicAuth user password //连接用户密码,需要对应版本1.10以后,否则服务启动失败
命令
service tinyproxy start
service tinyproxy restart
service tinyproxy stop
测试
curl -x <http://127.0.0.1:8787> www.baidu.com // 无需用户名密码
curl -x <http://user:password@127.0.0.1:8888> www.baidu.com // 需要用户名密码
客户端配置
MAC
在当前连接的网络中
服务器地址:腾讯云公网IP
端口:配置中Port:8888
设置了端口后请确认端口是否对外开放,防火墙是否允许
如果需要过滤掉某些网站不使用代理访问,则修改配置中#Filter "/etc/tinyproxy/filter"取消注释
并且添加到/etc/tinyproxy/filter文件中,如下:
# 精确过滤baidu.com
^baidu\\.com$
# 过滤baidu.com的所有子域名,但不过滤baidu.com
.*\\.baidu.com$
# 过滤所有包含baidu.com的域名
baidu\\.com
# 过滤以baidu.com结尾的域名
baidu\\.com$