0%

Linux配置Tinyproxy代理

tinyproxy

Tinyproxy是一个轻量级的http代理软件,速度快体积小,可以使用来把socks5代理转为http代理。测试环境为 :fire: ​ArchLinux,IP:172.16.10.18,Socks5端口1090.

1.查询软件包

1
2
3
~$ pacman -Ss tinyproxy
community/tinyproxy 1.10.0-2 [已安装]
A light-weight HTTP proxy daemon for POSIX operating systems.

2.安装tinyproxy

1
~$ sudo pacman -Sy tinyproxy

3.修改配置文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
~$ vim /etc/tinyproxy/tinyproxy.conf
User tinyproxy
Group tinyproxy

Port 8888

Listen 0.0.0.0

Timeout 600

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"

DefaultErrorFile "/usr/share/tinyproxy/default.html"


StatFile "/usr/share/tinyproxy/stats.html"

LogFile "/var/log/tinyproxy/tinyproxy.log"

#关闭syslog,使用自定义的日志文件
#Syslog On

LogLevel Info

PidFile "/var/run/tinyproxy/tinyproxy.pid"

# 在请求头中加入客户端IP
#XTinyproxy Yes

#设置上游代理,转换上游socks5代理为http代理
upstream socks5 127.0.0.1:1090

MaxClients 100

MinSpareServers 5
MaxSpareServers 20

StartServers 10

MaxRequestsPerChild 0

# 允许局域网的哪些主机访问
Allow 172.16.10.0/24
Allow 192.168.1.0/24

AddHeader "X-My-Header" "Powered by Tinyproxy"
ViaProxyName "tinyproxy"

4.启动服务

1
2
~$ sudo systemctl start tinyproxy.service
~$ sudo systemctl enable tinyproxy.service

5.测试

在局域网内的其它主机上把代理设置为上面的Tinyproxy,测试请求头信息

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
xdl@aml:~$ export http_proxy='http://172.16.10.18:8888'
xdl@aml:~$ export https_proxy='http://172.16.10.18:8888'

xdl@aml:~$ curl -I www.baidu.com
HTTP/1.0 200 OK
Via: 1.1 tinyproxy (tinyproxy/1.10.0) # <------ 请求头中包含了Tinyproxy
Cache-Control: private, no-cache, no-store, proxy-revalidate, no-transform
Content-Type: text/html
Etag: "575e1f6f-115"
Last-Modified: Mon, 13 Jun 2016 02:50:23 GMT
Pragma: no-cache
Server: bfe/1.0.8.18
Accept-Ranges: bytes
Date: Thu, 20 Aug 2020 06:57:01 GMT
Content-Length: 277

参考:

1.https://tinyproxy.github.io/

2.https://github.com/tinyproxy/tinyproxy

3.https://linux.cn/article-7119-1.html

如果对你有帮助,请我喝杯奶茶吧!
pengshp 微信

微信

pengshp 支付宝

支付宝

欢迎关注我的其它发布渠道