Case:
Web server: Domain name www.abc.com ip:192.168.21.129 Telecom Single line access
Access users: Telecommunications broadband users, mobile broadband users
Problems: Telecommunications users open www.abc.com Normal, mobile users open www.abc.com very slow, or even open
Solution: Place a CDN proxy server in the mobile computer room, through the intelligent DNS resolution, let the telecommunication user directly access the Web server, let the mobile user visit the CDN Proxy Server, solve the problem that the mobile user accesses the Web server slowly
Specific actions:
CDN Proxy Server:
System: CentOS 5.5 host Name: cdn.abc.com ip:192.168.21.160 Install squid software, configure reverse proxy to build CDN cache server
Pre-Installation Preparation:
1. Close SELinux
Vi/etc/selinux/config
#SELINUX =enforcing #注释掉
#SELINUXTYPE =targeted #注释掉
Selinux=disabled #增加
: Wq save, close.
Shutdown-r now reboot system
2, open the firewall 80 port (the following configuration squid port is 80)
Vi/etc/sysconfig/iptables
Add the following content
-A rh-firewall-1-input-m state--state new-m tcp-p TCP--dport 80-j ACCEPT
/etc/init.d/iptables Restart #重启防火墙使配置生效
3, modify the host routing mode
Vi/etc/sysctl.conf
Net.ipv4.ip_forward = 1 #0为关闭, 1 to open routing use sysctl-p command to view
4, modify host Hosts file, increase the domain name resolution record
Vi/etc/hosts
192.168.21.129 www.abc.com #添加解析记录
===========================================================================
Installation start
1. Install Squid
Yum Install squid #安装 (squid 2.6)
Service Squid start #启动
Service Squid Restart #重启
Chkconfig squid on #设置开机启动
2, Configuration Squid
Cp/etc/squid/squid.conf/etc/squid/squid.confbak #备份
Vi/etc/squid/squid.conf #编辑文件
Http_port Transparent #设置squid端口, the default is 3128, set to 80, when the client opens the Web site does not need to enter the port number
Cache_mem 1024 MB #分配内存大小
Cache_dir ufs/var/spool/squid 4096 256 #设置缓存文件大小
Cache_effective_user Squid #设置用户
Cache_effective_group Squid #设置用户组
Access_log/var/log/squid/access.log #设置访问日志文件
Cache_log/var/log/squid/cache.log #设置缓存日志文件
Cache_store_log/var/log/squid/store.log #设置缓存记录文件
Visible_hostname cdn.abc.com #设置squid服务器主机名
Cache_mgr root@abc.com #设置管理员邮箱 (set to your own email address)
ACL all src 0.0.0.0/0.0.0.0 #设置访问控制列表, default open
Http_access allow all #设置访问权限, default commented out
Cache_peer 192.168.21.129 0 no-query originserver name=web #用户访问web时, Squid sends a request to the 192.168.21.129 80 port
Cache_peer_domain Web www.abc.com #设置web域名为www. abc.com
Cache_peer_access Web Allow all #设置访问权限, allowing all external clients access to the Web
: wq! #保存退出
Service Squid Stop #停止
/usr/sbin/squid-z #初始化cache缓存目录
Service Squid start #启动
Squid Reverse proxy Server installation configuration complete
==================================================================
To enable smart DNS resolution:
if it is the telecommunications user access domain name www.abc.com parsing to 192.168.21.128
If you are a mobile user accessing the domain name www.abc.com parsing to 192.168.21.160
A dedicated line connection between CDN cache server and Web server