CentOS 7安裝squid代理服務器


Squid,一個高性能的代理緩存服務器,支持FTP、gopher、HTTP協議。

Squid,一個緩存Internet 數據的軟件,其接收用戶的下載申請(作為代理服務器),並自動處理所下載的數據,並返回給客戶。

當一個用戶想要下載一個主頁(如米撲科技:https://mimvp.com)時,可以向Squid 發出一個申請,讓Squid 代替其進行下載,然后Squid 連接所申請網站並請求該主頁,接着把該主頁傳給用戶同時保留一個備份,當別的用戶申請同樣的頁面時,Squid 把保存的備份立即傳給用戶,使用戶覺得速度相當快。Squid 可以代理HTTP、FTP、GOPHER、SSL和WAIS等協議並且Squid 可以自動地進行處理,可以根據自己的需要設置Squid,使之過濾掉不想要的東西。

centos-7-install-squid-proxy-server-00

Squid 是一個跨平台服務,可運行在大多數Unix和OS/2版本的系統之上,已知的可工作的有:

Windows,AIX,Digital Unix,FreeBSD,HP-UX,Irix,Linux,NetBSD,Nextstep,SCO,Solaris

Squid 官網http://www.squid-cache.org

 

 

安裝 squid

# rpm -qa | grep squid

squid-3.3.8-26.el7_2.4.x86_64            // 表示安裝過

yum -y install squid                             // 安裝

 

開機自啟動 squid

systemctl enable squid.service 

 

配置 squid

vim  /etc/squid/squid.conf

找到 

http_access deny all 

在之前添加下面數行內容:注意路徑 

auth_param basic program /usr/lib64/squid/basic_ncsa_auth /etc/squid/passwd 
auth_param basic children 5 
auth_param basic realm hehe 
auth_param basic credentialsttl 2 hours 
acl myproxy proxy_auth REQUIRED 
http_access allow myproxy 

增加2句隱藏真實ip變成匿名代理 這是squid 3.1的寫法 

via off 
forwarded_for delete 

 

squid 用戶名密碼認證

利用 apache 攜帶的工具 htpasswd 生成密碼文件並添加相應的用戶信息

/usr/bin/htpasswd -c /etc/squid/passwd  mimvp-guest

根據提示輸入密碼:Mimvp-COM-2016

成功后將會在 /etc/squid/passwd 中寫入:

# cat /etc/squid/passwd 
 mimvp-guest:$apr1$MsJeP9bZ$BLCJYnpQyFR.dV5SBDxMg0

第一列是用戶名,第二列是密碼

 

squid 參數檢查

squid -k parse 

去掉下面一行的注釋#,否則squid -z無法執行 

vim /etc/squid/squid.conf

#cache_dir ufs /var/spool/squid 100 16 256 

去掉后,初始化緩存 

squid -z 

# squid -z
[root@mimvp-bj script]# 2017/09/29 18:35:26 kid1| Set Current Directory to /var/spool/squid
2017/09/29 18:35:26 kid1| Creating missing swap directories
2017/09/29 18:35:26 kid1| No cache_dir stores are configured.

 

 

啟動服務 

systemctl start squid.service 

查看3128已經在運行服務了 

netstat -ntpl

# netstat -ntpl | grep 3128
tcp6       0      0 :::3128                 :::*                    LISTEN      29764/(squid-1)   

 

查看squid日志

tail -f  /var/log/squid/access.log

tail -f /var/log/squid/cache.log

 

設置代理測試驗證

操作系統:Mac OS X

代理服務器:58.87.90.149:3128

代理賬號密碼:mimvp-guest / mimvp.com

瀏覽器:Chrome Version 61.0.3163.100 (Official Build) (64-bit)

設置代理步驟:

1)瀏覽器設置系統級代理

Chrome —> 右上角  —> Settings  —> Advanced  —> Open proxy settings 

centos-7-install-squid-proxy-server-01

centos-7-install-squid-proxy-server-02

 

2)打開米撲代理的檢測代理網頁

檢測代理https://proxy.mimvp.com/check.php

centos-7-install-squid-proxy-server-03

如上圖,檢測出您當前IP為 58.87.90.149 ,其服務器位於北京,騰訊集團的雲服務器

 

以上,是通過瀏覽器設置的系統級代理,即代理一旦設定,電腦上的全部網絡鏈接都走的此代理

很多時候,我們不需要系統級代理,只是想在瀏覽器設置代理,其它網絡鏈接仍然是正常的,怎么設置呢?

答案是通過瀏覽器的插件實現,本文后面會推薦Chrome 和 Firefox 的插件,下面先看效果:

1) Chrome Proxy SwitchySharp 插件設置代理

centos-7-install-squid-proxy-server-04

 

2)Firefox Proxy Switcher 插件設置代理

centos-7-install-squid-proxy-server-05

輸入代理的用戶名和密碼

centos-7-install-squid-proxy-server-06

打開米撲代理的檢測代理網頁

檢測代理https://proxy.mimvp.com/check.php

centos-7-install-squid-proxy-server-08

 

好了,squid代理的安裝、配置,瀏覽器設置代理、插件設置代理、代理檢測驗證,都已經講完了

上面,代理檢測驗證,用到了米撲代理,他們是一家由百度、阿里、小米等技術工程師創業做的產品,非常好用

 

如果,您不想自己搭建代理服務器,可以直接用米撲代理,非常靠譜的一家代理公司

米撲代理https://proxy.mimvp.com   (國內第一家使用 HTTPS 加密網站的代理服務商)

米撲代理價格也很便宜:https://proxy.mimvp.com/price.php

centos-7-install-squid-proxy-server-09

 

 

瀏覽器設置代理的方法和插件

1. 五款瀏覽器設置代理教程

 

2. Chrome插件

1)Proxy SwitchySharp已不再維護,2014.3

SwitchySharp GitHubhttps://github.com/FelisCatus/switchysharp 

Manage and switch between multiple proxies quickly & easily. Based on "Proxy Switchy!" & "SwitchyPlus"

 

2)SwitchyOmegaSwitchySharp 升級版

SwitchyOmega GitHubhttps://github.com/FelisCatus/SwitchyOmega​

SwitchyOmega 是 switchysharp 的 2.x 升級版,支持 switchysharp 的全部功能,且包括了很多改進和修復。

SwitchyOmega 項目可以導入 SwitchySharp 的設置備份文件,並自動升級選項。

 

3. Firefox 插件

1)Best Proxy Switcher

公司官網:http://proxy-list.org

Best Proxy Switcher was developed by the team, who provides proxy service since 2004 year. You can use Best Proxy Switcher with your own proxy or let it download most recently checked list from our web site automatically!

For advanced users and web masters who needs more proxy servers, there is an option to register at our web site for 9.99 USD and get unlimited access to our database (please use 'register' button within addon to get special price) and fast secure VPN proxy servers.

Proxy-List.org web site offers more than 10.000 working proxy servers per day during 10 years! Our high quality service is confirmed by time and our clients!
 

 

2)Proxy Switcher

Access to the complete Firefox's proxy settings right from a toolbar panelThis extension provides a proxy settings UI very similar to Firefox's built-in proxy setting window but right from Firefox's toolbar panel.

The icon color changes based on your proxy setting to notify you about your proxy configuration.

The extension supports profiles. You can have up to 6 different profiles to manually configure all proxy settings.

 

3)FoxyProxy Standard

公司官網:https://getfoxyproxy.org

FoxyProxy是一個高級的代理管理工具,它完全替代了Firefox有限的代理功能。

它提供比SwitchProxy、ProxyButton、 QuickProxy、xyzproxy、ProxyTex、TorButton等等更多的功能。

FoxyProxy是一個Firefox擴展,它能自動切換一個或多個基於URL模式的代理服務器的網絡連接

簡單來說,Fox​​yProxy自動化了Firefox的連接設置對話框的手動編輯過程。代理服務器的切換基於加載的URL和你定義的交換規則。

當一個代理服務器正在使用時擴展會為你顯示動態圖標。高級日志顯示你何時用了哪一個代理。QuickAdd 功能使得它能快速創建新的URL模板。FoxyProxy完全兼容便攜式Firefox,比Firefox本身具有更好的PAC文件支持,並且它已經被翻譯成超過34種語言。

 

4)Hide My Ass! Web Proxy

公司官網:https://www.hidemyass.com

Hide My Ass! operates the most popular browser based web proxy online, this is our official extension that enables you to easily redirect your web traffic through our anonymous proxy network.Why use a web proxy?
1. Surf websites anonymously.
2. Hide and change your IP address (your 'online fingerprint').
3. Conceal your web browsing history.
4. SSL encryption for all websites.
5. Bypass web filters and geographic internet blocks.

 

 

參考推薦

centos7安裝代理服務器squid

使用Squid搭建HTTPS代理服務器

Centos7配置Shadowsocks5 代理服務器

CentOS 6.4下Squid代理服務器的安裝與配置

五款瀏覽器設置代理教程

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM