Overview of squid proxy server;
Overview: Squid Cache (SQUID for short) is http proxy server software. Squid is widely used as a cache server or a cache proxy server. It can be used as a proxy server for users to request data from the web server and cache it. It can filter traffic to help network security. It can also be used as a link in the proxy server chain to forward data to the superior proxy or directly connect to the Internet. It can also be used in local area network to enable local area network users to access the Internet through agents. Squid caches data in memory and also caches the results of DNS lookup. In addition, it supports non modular DNS lookup and negative caching of failed requests. Squid supports SSL and access control;
Advantages:
① Improve client access speed;
② Concealing the ip address of the internal host;
③ Simple deployment, access control can be realized;
1, Install squid
tar zxvf squid-3.4.6.tar.gz -C /opt cd squid-3.4.6.tar.gz yum install gcc gcc-c++ make -y #Install profile ./configure --prefix=/usr/local/squid \ --sysconfdir=/etc \ --enable-arp-acl \ --enable-linux-netfilter \ --enable-linux-tproxy \ --enable-async-io=100 \ --enable-err-language="Simplify_Chinese" \ --enable-underscore \ --enable-poll \ make && make install #Create a soft connection ln -s /usr/local/squid/sbin/* /usr/local/sbin/ #Create a procedural user useradd -M -s /sbin/nologin squid #add permission chown -R squid /usr/local/squid/var/ #Modify profile vim /etc/squid.conf
#Initialize cache squid -z #start-up squid
#Create script cd /etc/init.d/ vim squid #!/bin/bash #chkconfig: 2345 90 25 PID="/usr/local/squid/var/run/squid.pid" CONF="/etc/squid.conf" CMD="/usr/local/squid/sbin/squid" case "$1" in start) netstat -natp | grep squid &> /dev/null if [ $? -eq 0 ] then echo "squid is running" else echo "Starting up squid..." $CMD fi ;; stop) $CMD -k kill &> /dev/null rm -rf $PID &> /dev/null ;; status) [ -f $PID ] &> /dev/null if [ $? -eq 0 ] then netstat -natp | grep squid else echo "squid is not running" fi ;; restart) $0 stop &> /dev/null echo "Shutting down squid..." $0 start &> /dev/null echo "Starting up squid..." ;; reload) $CMD -k reconfigure ;; check) $CMD -k parse ;; *) echo "usage: $0(start|stop|status|reload|check|restart)" ;; esac
#add permission chmod +x squid #add name chkconfig --add squid #Start squid systemctl start squid
2, Traditional proxy server
Two servers, one for squid traditional agent and one for web
Proxy server address: 192.168.49.128
web server address: 192.168.49.129
vim /etc/squid.conf cache_mem 64 MB reply_body_max_size 10 MB maximum_object_size 4096 KB
#Clearing rules iptables -F #View rules iptables -L #Add to rule chain iptables -I INPUT -p tcp --dport 3128 -j ACCEPT #Restart service
3, Another web server
Install httpd
Turn off firewall
4, Verification:
Enter web server address
Enter the ip and port number of the proxy server, click save, and then close the browser
Reopen the browser and access the web again
cd /var/log/httpd/
Cat access log view log file
Show proxy address