前往小程序,Get更优阅读体验!
立即前往
发布
社区首页 >专栏 >centos 使用tinyproxy搭建 http代理服务

centos 使用tinyproxy搭建 http代理服务

作者头像
HHTjim 部落格
发布2025-02-26 09:38:35
发布2025-02-26 09:38:35
5200
代码可运行
举报
文章被收录于专栏:HHTjim'S 部落格
运行总次数:0
代码可运行

centos 使用tinyproxy搭建 http代理服务

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

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

环境: centos

install

代码语言:javascript
代码运行次数:0
复制
$ yum -y install tinyproxy

config

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

代码语言:javascript
代码运行次数:0
复制
# 设置代理端口
Port 8484 


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

run

代码语言:javascript
代码运行次数:0
复制
sudo service tinyproxy start

sudo service tinyproxy restart

sudo service tinyproxy stop

error

如果出现启动失败:

代码语言:javascript
代码运行次数:0
复制
[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

代码语言:javascript
代码运行次数:0
复制
[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官方没有提供镜像,这里使用三方

代码语言:javascript
代码运行次数:0
复制
# 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

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2024-10-31 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • centos 使用tinyproxy搭建 http代理服务
    • install
    • config
    • run
    • error
    • Docker
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档