Squid reverse proxy cdn build configuration
Because of the business needs of the company, you need to build a cdn node somewhere by yourself. You can build a node by using DNSpod smart resolution and squid combination.
Installation path:/usr/local/squid
1. Install squid
Download http://www.squid-cache.org/Versions/v3/3.4/squid-3.4.8.tar.gz
# Yum-y install gcc-c ++ # install the compilation plug-in # Tar xvf squid-3.4.8.tar.gz # cd squid-3.4.8 # cd/usr/local # mkdir squid # create a new name named squid directory # cd squid-3.4.8 #. /configure -- prefix =/usr/local/squid # compile # make & make install # install
Configuration 1
Create user squid and user group squid
# Groupadd squid
# Useradd-g squid-s/sbin // nologin squid
Configure the squid File
#vi /usr/local/squid/etc/squid.confvisible_hostname chengdu.sz1card1.comcache_effective_user squidcache_effective_group squidhttp_port 80 accel vhost vportcache_peer 192.168.1.11 parent 80 0 no-query originserver round-robin name=proxy1cache_peer 192.168.1.12 parent 80 0 no-query originserver round-robin name=proxy2cache_peer 192.168.1.13 parent 80 0 no-query originserver round-robin name=proxy3cache_peer_domain proxy1 server.1card1.cncache_peer_domain proxy2 www.abc.cncache_peer_domain proxy2 www.xxxx.cncache_peer_domain proxy3 www.abcd.comhttp_access allow allcache_log /usr/local/squid/var/logs/cache.logaccess_log /usr/local/squid/var/logs/access.log squidcache_dir ufs /usr/local/squid/var/cache 1000 16 256maximum_object_size 10240 KBmaximum_object_size_in_memory 1024 KBcache_mem 1024 MB
Configuration 2
# Chown-Rf squid: nobody/usr/local/squid
Initialize the cache directory configured in squid. conf to create a bunch of directories:
# Sudo/usr/local/squid/sbin/squid-z
Start squid background running
Sudo/usr/local/squid/sbin/squid-s
Check whether the process exists: ps-ef | grep squid
Common commands for routine maintenance of Squid:
1. initialize the cache directory you configured in squid. conf.
Squid-z
If an error message is displayed, check the permission of your cache directory.
You can use the following command to change the directory permissions:
Chown-R squid: squid/cache directory
2. Check the syntax and configuration of squid. conf.
Squid-k parse
If squid. conf has syntax or configuration errors, a prompt is returned. If no result is returned, start squid.
3. Start squid on the frontend and output the startup process.
/Usr/local/squid/sbin/squid-N-d1
If you have ready to server reques information, it indicates that Squid is successfully started.
Squid as the system service restart script
#!/bin/bash #chkconfig: 345 61 61# description: squid is a web cache server# processname: squid. /etc/rc.d/init.d/functionscase $1 in"start") /usr/local/squid/sbin/squid -sif [ $? == "0" ];thenecho "squid start ok"elseecho "please check the log"fi;;"stop") /usr/local/squid/sbin/squid -k shutdownif [ $? == "0" ];thenecho "squid stop ok"elseecho "please check the log"fi;;"restart")/usr/local/squid/sbin/squid -k shutdownif [ $? == "0" ];then/usr/local/squid/sbin/squid -sif [ $? == "0" ];thenecho "squid restart ok"else/usr/local/squid/sbin/squid -sif [ $? == "0" ];thenecho "squid restart ok"elseecho "please check the log"fififi;;*)echo "Usage only start|stop|restart";;esac
Put this file in the/etc/init. d/directory and name it squid.
Chmod + x/etc/init. d/squid
Chkconfig -- add squid
If the squid service does not support chkconfig
Then modify the preceding chkconfig: 345 61 61 numbers.