admin avatar

輕量級的HTTP/HTTPS代理服務程序-tinyproxy的安裝和配置

🕓 by admin

tinyproxy是一款輕量級的HTTP/HTTPS代理服務程序

非常輕量級,使用C語言編寫,系統佔用資源極低。

支持通過正則匹配域名黑白名單,代理鑑權,代理IP地址鎖定和端口設置

apt install tinyproxy安裝的tinyproxy版本不是新版

使用tinyproxy的鑑權功能必須要最新版才支持,目前tinyproxy最新版本已經提供編譯好的二進制執行文件

https://github.com/tinyproxy/tinyproxy/releases

下載好tinyproxy,直接把新版的tinyproxy替換成系統的tinyproxy即可

/etc/tinyproxy/tinyproxy.conf

1
2
3
4
5
6
7
# 註釋掉這一行
# Allow 127.0.0.1
# Allow 0.0.0.0
#上面的意思都是一樣的,如果只允許` Allow 127.0.0.1`則公網無法使用,只在本地使用
#也可以指定IP地址
# 修改端口號
Port 8787

1
2
3
4
5
6
7
8
systemctl start tinyproxy.service 
#啟動tinyproxy
systemctl stop tinyproxy.service
#停止tinyproxy
systemctl statustinyproxy.service
#檢測tinyproxy
systemctl restart tinyproxy.service
#重啟tinyproxy

查看tinyproxy日記,tailf /var/log/tinyproxy/tinyproxy.log

可以實時排查問題。

黑名單錄入

1
2
3
4
5
6
Filter "/etc/tinyproxy/filter"

FilterURLs On
FilterExtended On
FilterCaseSensitive On
FilterDefaultDeny No

1
2
3
4
5
6
7
8
9
10
11
12
13
#
# 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 :
當這個參數設置為No 或者 被註釋掉,就代表filter文件內的內容為黑名單
當這個參數設置為Yes 就代表filter內的內容為白名單。

比如/etc/tinyproxy/filter 配置的地址被禁止訪問,例如:

filter文件裡只有demo.com(此時FilterDefaultDeny為No) 那麼所有訪問demo.com的請求都會被禁止訪問.

白名單設置

修改 FilterDefaultDeny 為Yes,那麼filter文件裡所有地址都是可以訪問的.

参考

https://github.com/tinyproxy/tinyproxy

https://tinyproxy.github.io/

💘 相关文章

写一条评论