Squid Proxy Server 是一個功能豐富的 Web 服務器應用程序,可為您的網站提供反向代理服務和緩存選項。這大大加快了您的網站速度並減少了使用期間的加載時間。
Squids 反向代理是一種位於 Internet 和 Web 服務器(通常位於專用網絡中)之間的服務,可以輕鬆地將入站客戶端請求重定向到存儲數據的服務器。如果緩存服務器(代理)上沒有緩存數據,則將請求轉發到實際存儲數據的 Web 服務器。這種類型的緩存允許您收集數據並複制存儲在不同位置的原始數據值,以便於訪問。
反向代理通常提供額外的控制層來平滑客戶端和 Web 服務器之間的入站網絡流量。
Squid 可用作 SSL 請求和 DNS 查找的緩存服務。它還為其他幾種類型的緩存協議提供廣泛的支持,包括: ICP, HTCP, 鯉魚, 還 世界共產黨.Squid 非常適合多種類型的設置,因為它通過提供大量系統工具和使用的監控框架來提供非常細粒度的控制。 網絡管理協議 它為您的緩存需求提供了堅實的基礎。
專用的 Squid 緩存 在選擇用作代理服務器的計算機系統時,許多用戶擁有大量的物理內存 (RAM),因為 Squid 維護內存中的緩存以提高性能。確保。
安裝魷魚
首先,確保您的服務器是最新的。
[[email protected] ~]# apt-get update
Get:1 https://security.ubuntu.com/ubuntu xenial-security InRelease [109 kB]Hit:2 https://us.archive.ubuntu.com/ubuntu xenial InReleaseHit:3 https://ppa.launchpad.net/libreoffice/ppa/ubuntu xenial InReleaseGet:4 https://us.archive.ubuntu.com/ubuntu xenial-updates InRelease [109 kB]Get:5 https://us.archive.ubuntu.com/ubuntu xenial-backports InRelease [107 kB]Fetched 325 kB in 0s (567 kB/s)Reading package lists... Done
Next, at the terminal prompt, enter the following command to install the Squid server:
[[email protected] ~]# apt install squid
Reading package lists... DoneBuilding dependency treeReading state information... DoneThe following packages were automatically installed and are no longer required:linux-headers-4.4.0-141 linux-headers-4.4.0-141-generic linux-image-4.4.0-141-genericUse 'apt autoremove' to remove them.
The following additional packages will be installed:
libecap3 squid-common squid-langpack ssl-cert
Suggested packages:
squidclient squid-cgi squid-purge smbclient ufw winbindd openssl-blacklist
The following NEW packages will be installed:
libecap3 squid squid-common squid-langpack ssl-cert
0 upgraded, 5 newly installed, 0 to remove and 64 not upgraded.
Need to get 2,672 kB of archives.
After this operation, 10.9 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Fetched 2,672 kB in 0s (6,004 kB/s)
Preconfiguring packages ...
Selecting previously unselected package libecap3:amd64.
(Reading database ... 160684 files and directories currently installed.)
Preparing to unpack .../libecap3_1.0.1-3ubuntu3_amd64.deb ...
Unpacking libecap3:amd64 (1.0.1-3ubuntu3) ...
Selecting previously unselected package squid-langpack.
Preparing to unpack .../squid-langpack_20150704-1_all.deb ...
Unpacking squid-langpack (20150704-1) ...
Selecting previously unselected package squid-common.
Preparing to unpack .../squid-common_3.5.12-1ubuntu7.6_all.deb ...
Unpacking squid-common (3.5.12-1ubuntu7.6) ...
Selecting previously unselected package ssl-cert.
Preparing to unpack .../ssl-cert_1.0.37_all.deb ...
Unpacking ssl-cert (1.0.37) ...
Selecting previously unselected package squid.
Preparing to unpack .../squid_3.5.12-1ubuntu7.6_amd64.deb ...
Unpacking squid (3.5.12-1ubuntu7.6) ...
Processing triggers for libc-bin (2.23-0ubuntu10) ...
Processing triggers for systemd (229-4ubuntu21.16) ...
Processing triggers for ureadahead (0.100.0-19) ...
Setting up libecap3:amd64 (1.0.1-3ubuntu3) ...
Setting up squid-langpack (20150704-1) ...
Setting up squid-common (3.5.12-1ubuntu7.6) ...
Setting up ssl-cert (1.0.37) ...
Setting up squid (3.5.12-1ubuntu7.6) ...
Skipping profile in /etc/apparmor.d/disable: usr.sbin.squid
Processing triggers for libc-bin (2.23-0ubuntu10) ...
Processing triggers for systemd (229-4ubuntu21.16) ...
Processing triggers for ureadahead (0.100.0-19) ...
而已!安裝完成!
做魷魚
默認 Squid 配置文件位於: ‘/等/魷魚/ 對於目錄,主配置文件的名稱是“魷魚配置文件該文件包含一些配置指令,您可以更改它們以更改 Squid 的行為。#“被文件註釋掉或不被讀取。提供這些註釋是為了解釋相關配置設置的含義。
要編輯配置文件,請先備份原始文件,以防出現問題。您需要撤消更改或使用它們來比較新的文件配置。
[[email protected] ~]# cp /etc/squid/squid.conf /etc/squid/squid.conf.bak
更改 Squid 的默認監聽端口
其次,Squid 代理服務器的默認端口是 3128。如果您出於特定原因或需要更改端口,則可以更改或更改此設置以滿足您的需要。要更改默認 Squid 端口,請編輯 Squid 配置文件並單擊http_port將值(第 1599 行)更改為新的端口號。
[[email protected] ~]# vim /etc/squid/squid.conf
http_port 2946
((((暫時保持文件打開…)。
更改 Squid 的默認 HTTP 訪問端口
然後,為了使 HTTP 代理服務器可以從所有 IP 地址之外訪問,http_access “ 命令。默認情況下,除非您明確允許,否則 HTTP 代理服務器不允許任何人訪問。
溫暖的!: 提到多個設置 http_access..更改最後一個條目。
1164 # Deny requests to certain unsafe ports
1165 http_access deny !Safe_ports
...
1167 # Deny CONNECT to other than secure SSL ports
1168 http_access deny CONNECT !SSL_ports
...
1170 # Only allow cachemgr access from localhost
1171 http_access allow localhost manager
1172 http_access deny manager
...
1186 #http_access allow localnet
1187 http_access allow localhost
...
1189 # And finally deny all other access to this proxy
1190 http_access deny all
# > change to “allow all” <
現在讓我們使用vim來保存和關閉配置文件 : wq 命令。
定義 Squid 偵聽的默認 NIC 卡
如果您希望 Squid 偵聽特定的 NIC(在具有多個 NIC 卡的服務器中),您可以使用 Squid 偵聽的 NIC 的 IP 地址更新配置文件。
例如,您可以將其更改為內部 IP 10.1.1.5:3128
定義可以訪問代理服務器的用戶
接下來,設置允許訪問 Squid 代理的用戶。出現 http_access 取消註釋該部分(必須從第 1860 行開始)和接下來的兩行。#acl our_networks src 10.1.1.0/16 10.1.2.0/16
#http_access allow our_networks
-- VVV change to VVV --
acl our_networks src 10.1.1.0/16 10.1.2.0/16
http_access allow our_networks
除非有多個子網可用,否則您需要將 IP 範圍(10.1.1.0/16 10.1.2.0/16)更改為您自己的內部 IP,以匹配您網絡中使用的 IP。 ((((我們將在這裡更多地討論網絡掩碼。.. )
定義可訪問代理的時間
您實際上可以控制何時訪問代理服務器。 ACL 部分以 673 號線:671 # none
要設置它,請在 ACL 部分的底部添加此信息。 /etc/squid/squid.conf 文檔:
672
673 # TAG: acl
674 # Defining an Access List
675 #
acl CodePre src 10.1.10.0/24
當然這是一個用例 液網 您可以使用它作為您的公司名稱,但您可以使用任何您喜歡的名稱。
acl CodePre time M T W T F 9:00-17:00
其他 ACL 選項包括:
***** ACL TYPES AVAILABLE *****
711 #
712 # acl aclname src ip-address/mask ... # clients IP address [fast]
713 # acl aclname src addr1-addr2/mask ... # range of addresses [fast]
714 # acl aclname dst [-n] ip-address/mask ... # URL host's IP address [slow]
715 # acl aclname localip ip-address/mask ... # IP address the client connected to [fast]
717 # acl aclname arp mac-address ... (xx:xx:xx:xx:xx:xx notation)
...
730 # acl aclname srcdomain .foo.com ...
731 # # reverse lookup, from client IP [slow]
732 # acl aclname dstdomain [-n] .foo.com ...
733 # # Destination server from URL [fast]
734 # acl aclname srcdom_regex [-i] .foo.com ...
735 # # regex matching client name [slow]
736 # acl aclname dstdom_regex [-n] [-i] .foo.com …
…
… (all the way down to line 989)
…
968 # Example rule allowing access from your local networks.
969 # Adapt to list your (internal) IP networks from where browsing
970 # should be allowed
971 #acl localnet src 10.0.0.0/8 # RFC1918 possible internal network
972 #acl localnet src 172.16.0.0/12 # RFC1918 possible internal network
973 #acl localnet src 192.168.0.0/16 # RFC1918 possible internal network
974 #acl localnet src fc00::/7 # RFC 4193 local private network range
975 #acl localnet src fe80::/10 # RFC 4291 link-local (directly plugged) machines
976
977 acl SSL_ports port 443
978 acl Safe_ports port 80 # http
979 acl Safe_ports port 21 # ftp
980 acl Safe_ports port 443 # https
981 acl Safe_ports port 70 # gopher
982 acl Safe_ports port 210 # wais
983 acl Safe_ports port 1025-65535 # unregistered ports
984 acl Safe_ports port 280 # http-mgmt
985 acl Safe_ports port 488 # gss-http
986 acl Safe_ports port 591 # filemaker
987 acl Safe_ports port 777 # multiling http
988 acl CONNECT method CONNECT
989
所有魷魚配置選項
綜合會計 可用魷魚配置文件 您可以在這些鏈接中找到它。 (那裡有很多信息,所以請確保您計劃花一些時間)
重啟魷魚
進行這些更改後,重新啟動 Squid 服務並重新加載配置文件。
[[email protected] ~]# systemctl restart squid.service
其他重要 Squid 文件的位置

魷魚的詳細資料
你能幫助我嗎?
最有幫助的託管人員可以提供有關如何在某些環境中使用 Squid 的清晰和詳細信息。我們的支持團隊包括許多有才華的人,尤其是那些對本文中描述的網絡託管技術有深刻理解的人。如果您不確定執行此處描述的步驟,我們將通過電話、聊天或票證向您提供信息以指導您完成整個過程。今天就來幫忙吧!