天天看點

Tinyproxy支援權限校驗Basic HTTP Authentication

tinyproxy版本1.8.3不支援賬号密碼驗證,而新版本1.10.0支援

1、如果不需要鑒權,可以直接通過yum安裝1.8版本

2、需要鑒權則要使用1.10版本,yum安裝的最新版是1.8,隻能通過源碼安裝

一、yum安裝1.8.3

# 安裝
$ yum install tinyproxy

$ tinyproxy -v
tinyproxy 1.8.3

# 啟動 start|stop|status|restart
$ service tinyproxy start

# 解除安裝
$ yum erase tinyproxy      

二、編譯安裝1.10.0

下載下傳安裝包頁面

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

找到最新版本

Version 1.10.0 (2020-05-20)

看到新版本的介紹,已經增加了驗證

Add support for basic HTTP authentication      

1、安裝最新版

wget https://github.com/tinyproxy/tinyproxy/releases/download/1.10.0/tinyproxy-1.10.0.tar.gz

tar -zxvf tinyproxy-1.10.0.tar.gz

cd tinyproxy-1.10.0

# 編譯安裝
./configure && 
make && 
make install

$ which tinyproxy
/usr/local/bin/tinyproxy

$ tinyproxy -v
tinyproxy 1.10.0      

如果發現tinyproxy的版本沒有變化,則删除檔案重新進行編譯安裝

2、修改配置

/etc/tinyproxy/tinyproxy.conf

# 注釋掉這行,允許所有ip通路
# Allow 127.0.0.1

# 權限校驗
BasicAuth user 123456      

如果配置檔案不存在,則搜尋一下配置檔案路徑

$ find / -name tinyproxy.conf

# 拷貝一份配置檔案
$ cp tinyproxy.conf /etc/tinyproxy/tinyproxy.conf      

3、啟動

# 啟動(不采用背景啟動,友善調試)
$ tinyproxy -d -c /etc/tinyproxy/tinyproxy.conf

# 指定配置檔案啟動(背景啟動)
$ tinyproxy -c /etc/tinyproxy/tinyproxy.conf

# 殺掉程序
$ ps -ef|grep tinyproxy|grep -v grep|awk '{print "kill -9 "$2}'|sh      

4、測試

# 不加驗證參數不會正常傳回
$ curl -x http://127.0.0.1:8888 www.baidu.com
Proxy Authentication Required

# 正常傳回
$ curl -x http://user:[email protected]:8888 www.baidu.com
      

遇到的問題

1、之前通過yum安裝過1.8版本,又通過編譯安裝了1.10版本,版本号沒有變化

解決:

将tinyproxy徹底删除後重新編譯安裝

$ find / -name tinyproxy      

2、配置檔案不生效

看下是不是有多份配置檔案,最好通過

-c

指定配置檔案