squid installation and traditional mode

Keywords: Web Server network vim iptables

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;

① 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

#Create script
cd /etc/init.d/
vim squid

#chkconfig: 2345 90 25

case "$1" in
    netstat -natp | grep squid &> /dev/null
    if [ $? -eq 0 ]
      echo "squid is running"
      echo "Starting up squid..."
    $CMD -k kill &> /dev/null
    rm -rf $PID &> /dev/null
    [ -f $PID ] &> /dev/null
      if [ $? -eq 0 ]
        netstat -natp | grep squid
        echo "squid is not running"
    $0 stop &> /dev/null
    echo "Shutting down squid..."
    $0 start &> /dev/null
    echo "Starting up squid..."
    $CMD -k reconfigure
    $CMD -k parse
    echo "usage: $0(start|stop|status|reload|check|restart)"
#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:
web server address:

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

Published 52 original articles, won praise 9, visited 1602
Private letter follow

Posted by Sno on Tue, 11 Feb 2020 03:27:11 -0800