linux服務器設置成代理服務器

操作系統:阿里雲CentOS 7.4 64位

安裝方法:

yum install tinyproxy

配置:

vi /etc/tinyproxy/tinyproxy.conf

Port 8888 //預設是8888 Port,你可以更改

Allow 127.0.0.1 //將127.0.0.1改成你自己的IP

//Allow 192.168.1.0/24    #表示一個網絡的IP

//例如你的IP 是1.2.3.4,你改成Allow 1.2.3.4,那只有你纔可以連上這個Proxy

//若你想任何IP都可以連到Proxy在Allow前面打#註釋

啓動停止服務

chkconfig tinyproxy on

service tinyproxy start

service tinyproxy stop

service tinyproxy restart

上面的命令有點誤 

[root@alves bin]# systemctl tinyproxy start
Unknown operation 'tinyproxy'.
[root@alves bin]# systemctl tinyproxy.start start
Unknown operation 'tinyproxy.start'.
[root@alves bin]# systemctl tinyproxy.service start
Unknown operation 'tinyproxy.service'.
[root@alves bin]# service tinyproxy start
Redirecting to /bin/systemctl start tinyproxy.service
[root@alves bin]# /bin/systemctl start tinyproxy.service
[root@alves bin]# /bin/systemctl start tinyproxy.service

本地測試

打開終端輸入:

curl -x <IP>:<PORT> www.baidu.com

返回百度頁面代碼,說明代理成功。

其他

如果是阿里雲服務器,還需要配置一個安全規則,把你設置的代理端口配置進去:

查看代理請求日誌

tail -f /var/log/tinyproxy/tinyproxy.log
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章