Under linux set up the configuration method of CDN cache server through Squid reverse proxy

  • 2020-05-06 12:10:46
  • OfStack

Case:
Web server: domain name www.abc.com IP: 192.168.21.129 telecom single line access
Access users: telecom broadband users, mobile broadband users
Problems: telecom users open www.abc.com is normal, mobile users open www.abc.com is slow, or even unable to open
Solution: put an CDN proxy server in the mobile machine room, and through intelligent DNS analysis, let telecom users directly access Web server, let mobile users access CDN proxy server, and solve the problem of slow access to Web server by mobile users
Specific operation:
CDN proxy server:
System: CentOS 5.5 host name: cdn.abc.com IP:192.168.21.160 install Squid software, configure reverse proxy to set up CDN cache server
Preparation before installation:
1. Close SELinux
vi /etc/selinux/config
#SELINUX=enforcing # comment out
#SELINUXTYPE=targeted # comment out
SELINUX=disabled # increase
:wq save, close.
Es50en-r now restart system


2. Open firewall port 80 (port of squid configured later is 80)
vi /etc/sysconfig/iptables
Add
below -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
/ etc/init d/iptables restart # restart the firewall configuration validation


3, modify the host routing mode
vi /etc/sysctl.conf
Es83en.ipv4.ip_forward = 1 #0 to close, 1 to open the route use the sysctl-p command to view
4. Modify the host hosts file and add the domain name resolution record
vi /etc/hosts
192.168.21.129 www.abc.com # add resolution record


===========================================================================
installation starts
1. Install Squid
yum install squid # installation (Squid 2.6)
service squid start # starts
service squid restart # restart
chkconfig squid on # set to boot


2. Configure Squid
cp etc/squid/squid conf etc/squid/squid confbak # backup
vi etc/squid/squid conf
# editor file
http_port 80 transparent # set squid port to default to 3128 and set to 80. The client does not need to enter
port number when opening the website cache_mem 1024 MB # allocates memory size
cache_dir ufs /var/spool/squid 4096 16 256 # set the cache file size
cache_effective_user squid # sets user
cache_effective_group squid # set the user group
access_log/var/log/squid/access log
# set access log files cache_log/var/log/squid/cache log # set cache
log file cache_store_log/var/log/squid/store log # sets
cache record files visible_hostname cdn.abc.com # sets squid server hostname
cache_mgr root@abc.com # set the administrator mailbox (set to your own mailbox address)
acl all src 0.0.0.0/0.0.0.0 # set the access control list and
is turned on by default http_access allow all # sets access rights,
is commented out by default cache_peer 192.168.21.129 parent 80 0 no-query originserver name=web # when a user accesses web, Squid sends a request for
to port 80 of 192.168.21.129 cache_peer_domain web www. abc. com # set web domain to www. abc. com
cache_peer_access web allow all # sets access permissions to allow all external clients to access web

: wq! Save exit
service squid stop # stop
/usr/sbin/squid -z # initializes the cache cache directory
service squid start # start
Squid reverse proxy server installation configuration complete
==================================================================
enables smart DNS Es284en.abc.com resolves to 192.168.21.128
if it is a telecommunications user accessing the domain name www.abc.com If it is a mobile user accessing the domain name www.abc.com resolved to 192.168.21.160
The CDN cache server is connected to Web server by a dedicated line


Related articles: