Linux环境 tinyproxy安装配置及使用教程【超详细】

CentOS与Ubuntu下Tinyproxy的安装与配置详解

安装

# centos
sudo yum install tinyproxy
# ubuntu
sudo apt install tinyproxy

配置

vim /etc/tinyproxy/tinyproxy.conf

需要修改的是:

# 注释掉这一行
# Allow 127.0.0.1
# 修改端口号
Port 8787
  • Allow 是允许访问的主机IP,不写就是允许所有主机访问
  • Port 是代理访问端口号

启动/停止/查看状态/重启命令

systemctl start tinyproxy.service
systemctl stop tinyproxy.service
systemctl status tinyproxy.service
systemctl restart tinyproxy.service

查看日志

tailf /var/log/tinyproxy/tinyproxy.log

配置访问站点限制

黑名单设置

打开如下配置

Filter "/etc/tinyproxy/filter"

FilterURLs On
FilterExtended On
FilterCaseSensitive On
FilterDefaultDeny No

最需要注意的是这个参数

  • FilterDefaultDeny :
    当这个参数设置为No 或者 被注释掉,就代表filter文件内的内容为黑名单
    当这个参数设置为Yes 就代表filter内的内容为白名单。
#
# FilterDefaultDeny: Change the default policy of the filtering system.
# If this directive is commented out, or is set to "No" then the default
# policy is to allow everything which is not specifically denied by the
# filter file.
#
# However, by setting this directive to "Yes" the default policy becomes
# to deny everything which is _not_ specifically allowed by the filter
# file.
#

把上面几个配置放开后,如果不想让访问哪个地址,就在 /etc/tinyproxy/filter 文件里配置上对应的地址,默认是/etc/tinyproxy/filter 文件内的地址被禁止访问,例如:

我的filter文件里只写了cdh01(此时FilterDefaultDeny为No)

那么所有访问cdh01的请求都会被过滤掉,被禁止访问,效果如下:
当我访问Hue界面时报错:

白名单设置

修改 FilterDefaultDeny 为Yes


这就代表通过代理只能访问域名是这些的网站。

附录-我的配置文件

##
## tinyproxy.conf -- tinyproxy daemon configuration file
##
## This example tinyproxy.conf file contains example settings
## with explanations in comments. For decriptions of all
## parameters, see the tinproxy.conf(5) manual page.
##

#
# User/Group: This allows you to set the user and group that will be
# used for tinyproxy after the initial binding to the port has been done
# as the root user. Either the user or group name or the UID or GID
# number may be used.
#
User tinyproxy
Group tinyproxy

#
# Port: Specify the port which tinyproxy will listen on.  Please note
# that should you choose to run on a port lower than 1024 you w
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

香山上的麻雀1008

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值