SquidACL access control, reverse proxy, sarg log
Lab environment squid server ens33:192.168.13.184 ens36:192.168.10.1 (host mode only) web server 192.168.13.151client 192.168.10.10 (host mode only) one, ACL access control 1 Modify the configuration file on the squid server [root@squid ~] # vim / etc/squid.conf # # modify the configuration file # should be allowedacl hostlocal src 192.168.10.10 hostlocal10.10 32 # control the host # Deny requests to certain unsafe portshttp_access deny hostlocal # # refuse to access [root@squid ~] # service squid reload # # restart the squid service 2, access the web web page on the test machine
Second, sarg log 1 Install sargon [root @ squid ~] # mount.cifs / / 192.168.100.3/LNMP-C7 / mnt/ # # Mount Password for root@//192.168.100.3/LNMP-C7: [root@squid ~] # cd / mnt/ [root@squid mnt] # tar zxvf sarg-2.3.7.tar.gz-C / opt/ # # decompress [root@squid mnt] # cd / opt/sarg-2.3.7/ [root@squid sarg-2.3.7] # yum install gd gd-devel-y # # install the gd library [root@squid sarg-2.3.7] #. / configure-- prefix=/usr/local/sarg\ # # installation path >-- sysconfdir=/etc/sarg\ # configuration file >-- enable-extraprotection # # enable security protection [root@squid sarg-2.3.7] # make & & make install # # compile and install 2 Modify sarg configuration file [root@squid sarg-2.3.7] # vim / etc/sarg/sarg.conf # # modify sarg configuration file # # turn on access_log / usr/local/squid/var/logs/access.log # # specify access log file title "Squid User Access Reports" # # Page title output_dir / var/www/html/squid-reports # # report output directory user_ip no # # using user name to display exclude_hosts / usr/local/sarg/noreport # # the number of connections in the sorting of the site list file topuser_sort_field connect reverse # # top Access bytes, sort in descending order Ascending order is normaloverwrite_report no # # whether the log of the same name overrides mail_utility mailq.postfix # # send email report Command charset UTF-8 # # use the character set weekdays 0-6 # # top ranking time period hours 0-23 # # top ranking time period www_document_root / var/www/html # # Web page root directory [root@squid ~] # sarg # # generate report SARG: recorded in file: 91 Reading: 100.00%SARG: successful generation report in / var/www/html/squid-reports/2019Dec11-2019Dec12 [root@squid sarg-2.3.7] # cd / var/www/html/squid-reports/ # # switch to html directory [root@squid squid-reports] # ls2019Dec11-2019Dec12 images index.html [root@squid squid-reports] # yum install httpd-y # # install httpd service [root@squid squid-reports] # systemctl start httpd.service # # enable service [root@squid squid-reports] # systemctl stop firewalld.service # # disable firewall [root@squid squid-reports] # setenforce 03 Use the test machine to visit the web page to view the visit record
# # periodically scheduled task execution daily report crontabsarg-l / usr/local/squid/var/logs/access.log-o / var/www/html/squid-reports/-z-d $(date-d "1 day ago" +% d/%m/%Y)-$(date +% d/%m/%Y)
Third, squid reverse proxy squid server ens33:192.168.13.184 ens36:192.168.10.1 (host mode only) web1 server 192.168.13.151web2 server 192.168.13.185client 192.168.10.10 (host mode only) 1 Edit a web page content on the web1 server [root@web ~] # cd / var/www/html/ [root@web html] # vim index.html # # Edit the web page content this is test webpage 2, and visit the web page on the test machine
3. Edit a web page content on the web2 server [root@web2 ~] # systemctl stop firewalld.service # # turn off the firewall [root@web2 ~] # setenforce 0 [root@web2 ~] # yum install httpd-y # # install the httpd service [root@web2] # cd / var/www/html/ # # create web content [root@web2 html] # vim index.htmlthis is test2 web! [root@web2 html] # systemctl start httpd.service 4 Configure reverse proxy [root@localhost squid] # vim / etc/squid.conf# Squid normally listens to port 3128http_port 192.168.13.184 accel vhost vport # # on squid service to monitor native port 80 cache_peer 192.168.13.151 parent 800 no-query originserver round-robin max_conn=30 weight=1 name=web1## node server 1 maximum access 30, weight 1 Alias web1cache_peer 192.168.13.185 parent 800 no-query originserver round-robin max_conn=30 weight=1 name=web1cache_peer_domain web1 web2 www.yun.com # # access yun.com match web1,web2 node [root@localhost squid] # service squid restart # # restart squid service 5, configure the resolution domain address under the admin user of the test machine, and set the proxy
Thank you for reading!