TinyProxy 简易的http代理

 tinyproxy版本1.8.3不支持账号密码验证,而新版本1.10.0支持

1、如果不需要鉴权,可以直接通过yum安装1.8版本

2、需要鉴权则要使用1.10以上版本,yum安装的最新版是1.8,只能通过源码安装

  1. yum安装

yum -y install tinyproxy

    配置 /etc/tinyproxy/tinyproxy.conf

        默认端口是 8888

Port 8888
注释掉 Allow,表示允许所有人访问代理
#Allow 127.0.0.1
隐藏掉Via请求头部,去掉下面的注释
DisableViaHeader Yes
# 多个Allow 表示允许多个客户端ip进行连接
Allow 39.3.2.16
Allow 2.15.9.19
Allow 8.10.133.22
Allow 1.20.7.14
# 权限校验
BasicAuth user 123456

 

启动服务

systemctl start tinyproxy.service

添加防火墙

firewall-cmd --zone=public --add-port=8888/tcp --permanent
firewall-cmd --reload

然后在本机测试

export https_proxy=http://ip:port
export http_proxy=http://ip:port

curl https://www.baidu.com

# 有权限校验需要
 curl -x http://user:123456@127.0.0.1:8888 https://www.baidu.com

Python测试

import requests

PROXY = {
    'http': 'ip:port',
    'https': 'ip:port'
}

res = requests.get('https://www.baidu.com', proxies=PROXY)

编译安装

GitHub - tinyproxy/tinyproxy: tinyproxy - a light-weight HTTP/HTTPS proxy daemon for POSIX operating systems

wget https://github.com/tinyproxy/tinyproxy/releases/download/1.11.1/tinyproxy-1.11.1.tar.gz


tar xvf tinyproxy-1.11.1.tar.gz 
cd tinyproxy-1.11.1/
./configure 
make -j 4
make install
which tinyproxy
tinyproxy -v

配置文件路径在源码包

ls etc/tinyproxy.conf

# 复制配置文件
cp etc/tinyproxy.conf /etc/

 配置为系统服务

vim /usr/lib/systemd/system/tinyproxy.service


[Unit]
Description=Startup script for the tinyproxy server
After=network.target

[Service]
Type=forking
PIDFile=/var/run/tinyproxy/tinyproxy.pid
ExecStart=/usr/local/bin/tinyproxy -c /etc/tinyproxy.conf
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process

[Install]
WantedBy=multi-user.target

启动服务

systemctl daemon-reload
systemctl start tinyproxy

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值