Ինչպես տեղադրել և կարգավորել SQUID Proxy սերվերը RHEL/CENTOS-ում
SQUID պրոքսի սերվեր
Պրոքսի սերվերը սարք է, որը սովորաբար տեղադրված է հաճախորդի և այն նպատակակետի միջև, որին փորձում է հասնել օգտվողը: Այն կարող է ապահովել վստահված անձի ետևում գտնվող հաճախորդի անվտանգություն, անանունություն և նույնիսկ պաշտպանություն: Այս գործընթացում օգնելու համար կա Squid-ը, որը Red Hat-ի վեբ պրոքսի սերվեր է: Այն գտնվում է հաճախորդի և վեբ սերվերի միջև, որոնց օգտագործողը փորձում է միանալ: Շատ անգամ այս սարքերն օգտագործվում են, երբ ցանկանում եք վերահսկել մուտքը ինտերնետ (կարծում ենք՝ վեբ զտումը): Որպես վեբ վստահված անձ՝ այն կարող է նաև քեշավորել այն տվյալները, որոնք օգտատերերը պահանջում են համացանցից և դրանք տեղային հասանելի դարձնել՝ նվազեցնելով ձեր արտաքին սարքերի բեռը, ինչպիսիք են դարպասներն ու պատերը:
Squid պրոքսի սերվերը սովորաբար տեղադրվում է առանձին սերվերի վրա, քան բնօրինակ ֆայլերով վեբ սերվերը: Squid-ն աշխատում է ցանցի միջոցով օբյեկտների օգտագործման հետևանքով: Squid-ը սկզբում հանդես կգա որպես միջնորդ՝ պարզապես հաճախորդի հարցումը փոխանցելով սերվերին և պահպանելով պահանջվող օբյեկտի պատճենը: Եթե միևնույն հաճախորդը կամ մի քանի հաճախորդներ պահանջեն նույն օբյեկտը, նախքան դրա ժամկետի ավարտը Squid-ի քեշից, Squid-ը կարող է անմիջապես սպասարկել այն՝ արագացնելով ներբեռնումը և խնայելով թողունակությունը:
Կաղմարի փաթեթի տեղադրում՝
Լռելյայնորեն squid փաթեթը տեղադրված չէ, ստուգեք՝ արդյոք փաթեթը տեղադրված է, թե ոչ՝ օգտագործելով հետևյալ հրամանը։
[root@centos Desktop]# rpm -qa|grep squid
squid-3.3.8-26.el7.x86_64
Եթե փաթեթը տեղադրված չէ, տեղադրեք այն՝ օգտագործելով yum install հրամանը
[root@centos Desktop]# yum install squid
Loaded plugins: fastestmirror, langpacks
Resolving Dependencies
--> Running transaction check
---> Package squid.x86_64 7:3.3.8-26.el7 will be installed
--> Processing Dependency: libecap.so.2()(64bit) for package:
7:squid-3.3.8-26.el7.x86_64
--> Running transaction check
---> Package libecap.x86_64 0:0.2.0-9.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
====================================================================
Package Arch Version Repository Size
======================================================================
Installing:
squid x86_64 7:3.3.8-26.el7 base 2.6 M
Installing for dependencies:
libecap x86_64 0.2.0-9.el7 base 20 k
Transaction Summary
===========================================================================
Install 1 Package (+1 Dependent package)
Total download size: 2.6 M
Installed size: 8.6 M
Is this ok [y/d/N]: y
Downloading packages:
(1/2): libecap-0.2.0-9.el7.x86_64.rpm | 20 kB 00:17
(2/2): squid-3.3.8-26.el7.x86_64.rpm | 2.6 MB 00:25
----------------------------------------------------------------------------
Total 103 kB/s | 2.6 MB 00:25
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : libecap-0.2.0-9.el7.x86_64 1/2
Installing : 7:squid-3.3.8-26.el7.x86_64 2/2
Verifying : 7:squid-3.3.8-26.el7.x86_64 1/2
Verifying : libecap-0.2.0-9.el7.x86_64 2/2
Installed:
squid.x86_64 7:3.3.8-26.el7
Dependency Installed:
libecap.x86_64 0:0.2.0-9.el7
Complete!
Գործարկեք ծառայությունը և սահմանեք, որ այն սկսվի Boot time-ում:
[root@centos Desktop]# systemctl enable squid
Created symlink from /etc/systemd/system/multi-user.target.wants
/squid.service to /usr/lib/systemd/system/squid.service.
[root@centos Desktop]# systemctl start squid
[root@centos Desktop]# systemctl status squid
● squid.service - Squid caching proxy
Loaded: loaded (/usr/lib/systemd/system/squid.service; enabled;
vendor preset: disabled)
Active: active (running) since Mon 2016-03-21 13:00:11 IST; 7s ago
Process: 16554 ExecStart=/usr/sbin/squid $SQUID_OPTS -f $SQUID_CONF
(code=exited, status=0/SUCCESS)
Process: 16542 ExecStartPre=/usr/libexec/squid/cache_swap.sh
(code=exited, status=0/SUCCESS)
Main PID: 16601 (squid)
CGroup: /system.slice/squid.service
├─16601 /usr/sbin/squid -f /etc/squid/squid.conf
├─16603 (squid-1) -f /etc/squid/squid.conf
└─16657 (logfile-daemon) /var/log/squid/access.log
Mar 21 13:00:10 centos systemd[1]: Starting Squid caching proxy...
Mar 21 13:00:11 centos squid[16601]: Squid Parent: will start 1 kids
Mar 21 13:00:11 centos squid[16601]: Squid Parent:squid-1 process16603 ...ed
Mar 21 13:00:11 centos systemd[1]: Started Squid caching proxy.
Hint: Some lines were ellipsized, use -l to show in full.
[root@centos Desktop]#
Squid-ի հիմնական կազմաձևման ֆայլը կարող է գտնվել /etc/squid/squid.conf հասցեում:
squid.conf ֆայլի օրինակելի կոդը հետևյալն է
#
Recommended minimum configuration:
#
Example rule allowing access from your local networks.
Adapt to list your (internal) IP networks from where browsing
should be allowed
acl localnet src 10.0.0.0/8 # RFC1918 possible internal network
acl localnet src 172.16.0.0/12 # RFC1918 possible internal network
acl localnet src 192.168.0.0/16 # RFC1918 possible internal network
acl localnet src fc00::/7 # RFC 4193 local private network range
acl localnet src fe80::/10 # RFC 4291 link-local (directly plugged)
machines
acl SSL_ports port 443
acl Safe_ports port 80 # http
acl Safe_ports port 21 # ftp
acl Safe_ports port 443 # https
acl Safe_ports port 70 # gopher
acl Safe_ports port 210 # wais
acl Safe_ports port 1025-65535 # unregistered ports
acl Safe_ports port 280 # http-mgmt
acl Safe_ports port 488 # gss-http
acl Safe_ports port 591 # filemaker
acl Safe_ports port 777 # multiling http
acl CONNECT method CONNECT
#
Recommended minimum Access Permission configuration:
#
Deny requests to certain unsafe ports
http_access deny !Safe_ports
Deny CONNECT to other than secure SSL ports
http_access deny CONNECT !SSL_ports
Only allow cachemgr access from localhost
http_access allow localhost manager
http_access deny manager
We strongly recommend the following be uncommented to protect innocent
web applications running on the proxy server who think the only
one who can access services on "localhost" is a local user
#http_access deny to_localhost
#
INSERT YOUR OWN RULE(S) HERE TO ALLOW ACCESS FROM YOUR CLIENTS
#
Example rule allowing access from your local networks.
Adapt localnet in the ACL section to list your (internal) IP networks
from where browsing should be allowed
http_access allow localnet
http_access allow localhost
And finally deny all other access to this proxy
http_access deny all
Squid normally listens to port 3128
http_port 3128
Uncomment and adjust the following to add a disk cache directory.
#cache_dir ufs /var/spool/squid 100 16 256
Leave coredumps in the first cache dir
coredump_dir /var/spool/squid
#
Add any of your own refresh_pattern entries above these.
#
refresh_pattern ^ftp: 1440 20% 10080
refresh_pattern ^gopher: 1440 0% 1440
refresh_pattern -i (/cgi-bin/|\?) 0 0% 0
refresh_pattern . 0 20% 4320
Մեկնաբանություններից հանել և կարգավորել հետևյալը՝ քեշի գրացուցակը ավելացնելու համար:
Վերագործարկեք squid ծառայությունը և Add firewall կանոնը, որպեսզի թույլատրվի squid 3128 նավահանգիստը:
[root@centos Desktop]# systemctl restart squid
firewall-cmd –zone=public –add-port=3128/tcp –մշտական
Պահպանեք կանոնները և վերագործարկեք ծառայությունը:
firewall-cmd –վերբեռնում
Կազմաձևման ավարտված մասն այժմ ժամանակն է ստուգելու զննարկումը, որը ցույց է տալիս squid ip-ը և հաճախորդի բրաուզերում լռելյայն միացքը:
Բացեք firefox զննարկիչը և անցեք Գործիքներ > Ընտրանքներ > Ընդլայնված ներդիր > Ցանց > Կարգավորումներ > ընտրեք ձեռքով վստահված անձի կարգավորումներ ռադիո կոճակը և տրամադրեք կաղամար սերվերի IP 10.0.0.1 (այստեղ ես օգտագործել եմ սերվերի ip հասցեն 10.0.0.1) և պորտ 3128 և ստուգեք օգտագործումը: սա օգտագործեք այս վստահված սերվերը բոլոր արձանագրությունների համար, այնուհետև կտտացրեք լավ:
տես squid access.log ֆայլը՝ օգտագործելով հետևյալ հրամանը.
tail -f /var/log/squid/access.log
Այժմ վայելեք ինտերնետը և խնայեք ձեր թողունակությունը՝ օգտագործելով քեշ սերվերը: