centos 使用tinyproxy搭建 http代理服务

作者:matrix 被围观: 158 次 发布时间:2024-10-31 分类:Linux | 无评论 »

tinyproxy可以很轻量化的实现自己的http代理服务

环境: centos

install

$ yum -y install tinyproxy

config

/etc/tinyproxy/tinyproxy.conf 为配置文件

# 设置代理端口
Port 8484 


# 允许连接的客户端IP
Allow 127.0.0.1
Allow 101.1.1.1

run


sudo service tinyproxy start sudo service tinyproxy restart sudo service tinyproxy stop

error

如果出现启动失败:

[root@VM-0-3-centos tinyproxy]# systemctl status tinyproxy.service
● tinyproxy.service - Startup script for the tinyproxy server
   Loaded: loaded (/usr/lib/systemd/system/tinyproxy.service; enabled; vendor preset: disabled)
   Active: failed (Result: protocol) since Fri 2022-01-14 03:20:13 CST; 4s ago
  Process: 10140 ExecStart=/usr/sbin/tinyproxy -c /etc/tinyproxy/tinyproxy.conf (code=exited, status=0/SUCCESS)

Jan 14 03:20:13 VM-0-3-centos systemd[1]: Starting Startup script for the tinyproxy server...
Jan 14 03:20:13 VM-0-3-centos systemd[1]: Can't open PID file /var/run/tinyproxy/tinyproxy.pid (yet?) after start: No such file...rectory
Jan 14 03:20:13 VM-0-3-centos systemd[1]: Daemon never wrote its PID file. Failing.
Jan 14 03:20:13 VM-0-3-centos systemd[1]: Failed to start Startup script for the tinyproxy server.
Jan 14 03:20:13 VM-0-3-centos systemd[1]: Unit tinyproxy.service entered failed state.
Jan 14 03:20:13 VM-0-3-centos systemd[1]: tinyproxy.service failed.

需要重新修改service启动脚本
/lib/systemd/system/tinyproxy.service

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

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

[Install]
WantedBy=multi-user.target

Docker

除了上面手动安装,其实 docker 方式也很方便。

tinyproxy官方没有提供镜像,这里使用三方

# 8484 端口 && 限制访问者IP
docker run --rm  -it --network host -e PORT=8484   -e ALLOWED_NETWORKS="101.1.1.1 127.0.0.1"  docker.io/kalaksi/tinyproxy 


docker run --rm  -it -p 8484:8888 -e ALLOWED_NETWORKS="101.1.1.1 127.0.0.1" docker.io/kalaksi/tinyproxy 

# 使用文件配置
docker run --rm  -it --network host -v $(pwd)/tinyproxy.conf:/etc/tinyproxy/tinyproxy.conf docker.io/kalaksi/tinyproxy 

https://github.com/kalaksi/docker-tinyproxy

https://github.com/StreisandEffect/streisand/issues/1381

https://www.cnblogs.com/hanzhi/articles/10729013.html

Install Tinyproxy on Centos 7

其他文章:
本文固定链接:https://www.hhtjim.com/centos-tinyproxy.html
matrix
本文章由 matrix 于2024年10月31日发布在Linux分类下,目前没有通告,你可以至底部留下评论。
转载请注明:centos 使用tinyproxy搭建 http代理服务-HHTjim'S 部落格
关键字:, , , ,

添加新评论 »

 🙈 😱 😂 😛 😭 😳 😀 😆 👿 😉 😯 😮 😕 😎 😐 😥 😡 😈 💡

插入图片

NOTICE: You should type some Chinese word (like “你好”) in your comment to pass the spam-check, thanks for your patience!