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

article/2025/10/8 19:25:59

安装

# 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 will need
# to start tinyproxy using root.
#
Port 8787#
# Listen: If you have multiple interfaces this allows you to bind to
# only one. If this is commented out, tinyproxy will bind to all
# interfaces present.
#
#Listen 192.168.0.1#
# Bind: This allows you to specify which interface will be used for
# outgoing connections.  This is useful for multi-home'd machines where
# you want all traffic to appear outgoing from one particular interface.
#
#Bind 192.168.0.1#
# BindSame: If enabled, tinyproxy will bind the outgoing connection to the
# ip address of the incoming connection.
#
#BindSame yes#
# Timeout: The maximum number of seconds of inactivity a connection is
# allowed to have before it is closed by tinyproxy.
#
Timeout 600#
# ErrorFile: Defines the HTML file to send when a given HTTP error
# occurs.  You will probably need to customize the location to your
# particular install.  The usual locations to check are:
#   /usr/local/share/tinyproxy
#   /usr/share/tinyproxy
#   /etc/tinyproxy
#
#ErrorFile 404 "/usr/share/tinyproxy/404.html"
#ErrorFile 400 "/usr/share/tinyproxy/400.html"
#ErrorFile 503 "/usr/share/tinyproxy/503.html"
#ErrorFile 403 "/usr/share/tinyproxy/403.html"
#ErrorFile 408 "/usr/share/tinyproxy/408.html"#
# DefaultErrorFile: The HTML file that gets sent if there is no
# HTML file defined with an ErrorFile keyword for the HTTP error
# that has occured.
#
DefaultErrorFile "/usr/share/tinyproxy/default.html"#
# StatHost: This configures the host name or IP address that is treated
# as the stat host: Whenever a request for this host is received,
# Tinyproxy will return an internal statistics page instead of
# forwarding the request to that host.  The default value of StatHost is
# tinyproxy.stats.
#
#StatHost "tinyproxy.stats"
##
# StatFile: The HTML file that gets sent when a request is made
# for the stathost.  If this file doesn't exist a basic page is
# hardcoded in tinyproxy.
#
StatFile "/usr/share/tinyproxy/stats.html"#
# LogFile: Allows you to specify the location where information should
# be logged to.  If you would prefer to log to syslog, then disable this
# and enable the Syslog directive.  These directives are mutually
# exclusive.
#
LogFile "/var/log/tinyproxy/tinyproxy.log"#
# Syslog: Tell tinyproxy to use syslog instead of a logfile.  This
# option must not be enabled if the Logfile directive is being used.
# These two directives are mutually exclusive.
#
#Syslog On#
# LogLevel: 
#
# Set the logging level. Allowed settings are:
#	Critical	(least verbose)
#	Error
#	Warning
#	Notice
#	Connect		(to log connections without Info's noise)
#	Info		(most verbose)
#
# The LogLevel logs from the set level and above. For example, if the
# LogLevel was set to Warning, then all log messages from Warning to
# Critical would be output, but Notice and below would be suppressed.
#
LogLevel Info#
# PidFile: Write the PID of the main tinyproxy thread to this file so it
# can be used for signalling purposes.
#
PidFile "/var/run/tinyproxy/tinyproxy.pid"#
# XTinyproxy: Tell Tinyproxy to include the X-Tinyproxy header, which
# contains the client's IP address.
#
#XTinyproxy Yes#
# Upstream:
#
# Turns on upstream proxy support.
#
# The upstream rules allow you to selectively route upstream connections
# based on the host/domain of the site being accessed.
#
# For example:
#  # connection to test domain goes through testproxy
#  upstream testproxy:8008 ".test.domain.invalid"
#  upstream testproxy:8008 ".our_testbed.example.com"
#  upstream testproxy:8008 "192.168.128.0/255.255.254.0"
#
#  # no upstream proxy for internal websites and unqualified hosts
#  no upstream ".internal.example.com"
#  no upstream "www.example.com"
#  no upstream "10.0.0.0/8"
#  no upstream "192.168.0.0/255.255.254.0"
#  no upstream "."
#
#  # connection to these boxes go through their DMZ firewalls
#  upstream cust1_firewall:8008 "testbed_for_cust1"
#  upstream cust2_firewall:8008 "testbed_for_cust2"
#
#  # default upstream is internet firewall
#  upstream firewall.internal.example.com:80
#
# The LAST matching rule wins the route decision.  As you can see, you
# can use a host, or a domain:
#  name     matches host exactly
#  .name    matches any host in domain "name"
#  .        matches any host with no domain (in 'empty' domain)
#  IP/bits  matches network/mask
#  IP/mask  matches network/mask
#
#Upstream some.remote.proxy:port#
# MaxClients: This is the absolute highest number of threads which will
# be created. In other words, only MaxClients number of clients can be
# connected at the same time.
#
MaxClients 100#
# MinSpareServers/MaxSpareServers: These settings set the upper and
# lower limit for the number of spare servers which should be available.
#
# If the number of spare servers falls below MinSpareServers then new
# server processes will be spawned.  If the number of servers exceeds
# MaxSpareServers then the extras will be killed off.
#
MinSpareServers 5
MaxSpareServers 20#
# StartServers: The number of servers to start initially.
#
StartServers 10#
# MaxRequestsPerChild: The number of connections a thread will handle
# before it is killed. In practise this should be set to 0, which
# disables thread reaping. If you do notice problems with memory
# leakage, then set this to something like 10000.
#
MaxRequestsPerChild 0#
# Allow: Customization of authorization controls. If there are any
# access control keywords then the default action is to DENY. Otherwise,
# the default action is ALLOW.
#
# The order of the controls are important. All incoming connections are
# tested against the controls based on order.
#
#Allow 127.0.0.1#
# AddHeader: Adds the specified headers to outgoing HTTP requests that
# Tinyproxy makes. Note that this option will not work for HTTPS
# traffic, as Tinyproxy has no control over what headers are exchanged.
#
#AddHeader "X-My-Header" "Powered by Tinyproxy"#
# ViaProxyName: The "Via" header is required by the HTTP RFC, but using
# the real host name is a security concern.  If the following directive
# is enabled, the string supplied will be used as the host name in the
# Via header; otherwise, the server's host name will be used.
#
ViaProxyName "tinyproxy"#
# DisableViaHeader: When this is set to yes, Tinyproxy does NOT add
# the Via header to the requests. This virtually puts Tinyproxy into
# stealth mode. Note that RFC 2616 requires proxies to set the Via
# header, so by enabling this option, you break compliance.
# Don't disable the Via header unless you know what you are doing...
#
#DisableViaHeader Yes#
# Filter: This allows you to specify the location of the filter file.
#
Filter "/etc/tinyproxy/filter"#
# FilterURLs: Filter based on URLs rather than domains.
#
FilterURLs On#
# FilterExtended: Use POSIX Extended regular expressions rather than
# basic.
#
FilterExtended On#
# FilterCaseSensitive: Use case sensitive regular expressions.
#
FilterCaseSensitive On#
# 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.
#
#FilterDefaultDeny Yes#
# Anonymous: If an Anonymous keyword is present, then anonymous proxying
# is enabled.  The headers listed are allowed through, while all others
# are denied. If no Anonymous keyword is present, then all headers are
# allowed through.  You must include quotes around the headers.
#
# Most sites require cookies to be enabled for them to work correctly, so
# you will need to allow Cookies through if you access those sites.
#
#Anonymous "Host"
#Anonymous "Authorization"
#Anonymous "Cookie"#
# ConnectPort: This is a list of ports allowed by tinyproxy when the
# CONNECT method is used.  To disable the CONNECT method altogether, set
# the value to 0.  If no ConnectPort line is found, all ports are
# allowed (which is not very secure.)
#
# The following two ports are used by SSL.
#
ConnectPort 443
ConnectPort 563#
# Configure one or more ReversePath directives to enable reverse proxy
# support. With reverse proxying it's possible to make a number of
# sites appear as if they were part of a single site.
#
# If you uncomment the following two directives and run tinyproxy
# on your own computer at port 8888, you can access Google using
# http://localhost:8888/google/ and Wired News using
# http://localhost:8888/wired/news/. Neither will actually work
# until you uncomment ReverseMagic as they use absolute linking.
#
#ReversePath "/google/"	"http://www.google.com/"
#ReversePath "/wired/"	"http://www.wired.com/"#
# When using tinyproxy as a reverse proxy, it is STRONGLY recommended
# that the normal proxy is turned off by uncommenting the next directive.
#
#ReverseOnly Yes#
# Use a cookie to track reverse proxy mappings. If you need to reverse
# proxy sites which have absolute links you must uncomment this.
#
#ReverseMagic Yes#
# The URL that's used to access this reverse proxy. The URL is used to
# rewrite HTTP redirects so that they won't escape the proxy. If you
# have a chain of reverse proxies, you'll need to put the outermost
# URL here (the address which the end user types into his/her browser).
#
# If not set then no rewriting occurs.
#
#ReverseBaseURL "http://localhost:8888/"

http://chatgpt.dhexx.cn/article/xqb0OBb5.shtml

相关文章

CentOS 7 搭建 TinyProxy 代理

Tinyproxy是一个轻量级的用于POSIX操作系统的http/https代理守护进程。在设计之初就遵循着更快并且更小的原则。在相关的运用案例中,它是一种理想的解决方案,例如在一个需要全部HTTP代理特性的嵌入式部署的案例中。然而,对于需要更大的代理案…

使用TinyProxy搭建代理服务器

背景 办公电脑所在网络无法连接外网,机房服务器可以连接外网,通过服务器代理上网; 一、CentOS下TinyProxy安装–搭建代理服务器 TinyProxy是个轻量级简单的HTTP/HTTPS代理程序,GitHub和官网,安装方式这里主要介绍两…

centos7 搭建 tinyProxy代理

文章转载于:https://www.cnblogs.com/gezp/p/14962924.html 一、简介 Tinyproxy是一个轻量级的用于POSIX操作系统的http/https代理守护进程。在设计之初就遵循着更快并且更小的原则。在相关的运用案例中,它是一种理想的解决方案,例如在一个需…

使用TinyProxy搭建代理

本次基于Ubuntu 18.04搭建 0x01.下载TinyProxy(服务器) 步骤一:安装TinyProxy sudo apt install tinyproxy 步骤二:如 安装后提示 Use apt autoremove to remove them.错误 ,请先执行 sudo apt autoremove 命令,再执行sudo a…

Ubuntu tinyproxy

安装 yum install tinyproxy #失败 dnf install tinyproxy #失败yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm #成功 ubuntu 新系统 #设置密码 sudo passwd #登录 su #更新系统 apt-get update apt-get upgrade#安装tinyproxy apt-g…

利用tinyproxy云服务器配置成代理服务器

云服务配置成代理服务器 什么是正向代理? 简而言之就是: 隐藏自己的客户端,通过一个代理服务器来对目标服务器进行访问。服务器端不知道是你在对他进行请求访问。 如果一个服务器限制了ip来源,可以尝试使用正向代理来进行访问。 实战: 云服务器IP &…

腾讯云服务器Ubuntu、Centos7配置为代理服务器,使用tinyproxy

1.安装tinyproxy 1.1Ubuntu系统 apt-get install tinyproxy 1.2Centos7系统​​​​​​​ yum -y install tinyproxy 2.修改tinyproxy配置 vi /etc/tinyproxy/tinyproxy.conf 主要有两处配置 2.1端口配置 注意需要在你的防火墙中开启你设置的端口号 这是默认端口号…

轻量级的开源代理服务器Tinyproxy安装与配置

TinyProxy Tinyproxy 是一个面向 POSIX 系统开发的轻量级的开源 HTTP/HTTPS 代理守护进程,其从底层开始进行设计,保证了在高速的同时体积依然很小。它很适合用于需要完整 HTTP 代理特性,但系统资源又不足以运行大型代理的场景,比…

最新TinyProxy联通卡 停机卡tiny免流模式

tiny模式,默认接点,具体自测 首先下载tiny:https://wwa.lanzous.com/iV6Qdm8qgre 打开tiny,点击右上角将模式复制粘贴进去,完成保存,先查询现有的流量,然后下载一个小软件,过一段时…

java 取交集方法retainAll

java 取交集方法retainAll 有两个集合newCoures和oldCourses,判断这两个集合是否包含相同的对象或元素, 可以使用retainAll方法:oldCourses.retainAll(newCoures)。 如果存在相同元素,oldCourses中仅保留相同的元素。 如果不存…

Java List retainAll 记录坑

描述 我们知道使用List的retainAll方法可以获取两个集合的交集&#xff0c;但是在某些情况下方法的返回值并非我们想象那样。 现象 先看两个例子&#xff1a; public static void main(String[] args) {List<String> a new ArrayList<>();a.add("READ&quo…

关于ArrayList中的retainAll的一些思考

思考 我们都知道&#xff0c;比较两个对象的是否相同&#xff0c;一般是先通过hashcode方法比较hash值是否相等&#xff0c;如果相同&#xff08;哈希碰撞&#xff09;然后通过equals进行比较各个属性值是否相同&#xff0c;如果都相同&#xff0c;那么才是真正的相同。 我们…

java集合中retainAll方法

我们先来看看retainAll的源码 public boolean retainAll(Collection<?> c) {return batchRemove(c, true); } private boolean batchRemove(Collection<?> c, boolean complement) {//获得当前对象的所有元素final Object[] elementData this.elementData;//w…

Java取交集方法retainAll()

1 retainAll方法示例 如何判断一个集合与另外一个集合中有相同的元素 例如A.retainAll(B); 如果AB中有相同的元素&#xff0c;那么A中会保留相同的元素&#xff0c;将不同的元素移除 如果AB中没有相同的元素&#xff0c;那么会返回[] 当A中的元素有变化时会返回true&#…

Java中取多个集合的交集——retainAll()

Java中取多个集合的交集 集合 Collection 接口中定义了 retainAll()方法 retainAll() Retains only the elements in this set that are contained in the specified collection (optional operation). In other words, removes from this set all of its elements that are …

测试工程师面试题答案分类详解

数据库最基本的增&#xff0c;删&#xff0c;改&#xff0c;查&#xff0c; 假设表结构为&#xff1a; create table student( sid number, sname varchar2(50) ) 1.增加&#xff1a;insert into student values(1,张三) 2.删除&#xff1a;delete from student 3.…

软件测试工程师面试题及答案

软件测试工程师试题 一、填空 1、软件测试阶段的基本任务应当是根据软件开发各阶段的 和程序的 &#xff0c;精心设计一批“高产”的测试用例&#xff0c;利用这些测试用例 &#xff0c;找出软件中潜藏的各种错误和缺陷。 2、测试用例不仅要选用合理的测试输入数据&…

测试笔试题

做了几套题&#xff0c;个别题竟然错了。汗颜。摘录下&#xff1a; 1.有关字节换算的 字节 byte&#xff1a;8个二进制位为一个字节(B)&#xff0c;最常用的单位&#xff0c;字节也就是B。 1KB (Kilobyte 千字节)1024B 1MB (Megabyte 兆字节 简称“兆”)1024KBA 1GB (Giga…

测试工程师面试题

选择题 进行兼容性测试的目的在于&#xff08;&#xff09; A、测试程序在不同的平台上可以正常运行B、测试程序与平台上的其他程序可以同时正常运行C、测试数据格式在不同应用程序之间可以通用D、以上选项都正确 某个 Android 应用耗电问题严重&#xff0c;以下那个是可能的…