Use Squid reverse proxy to build a CDN cache server to speed up Web Access

Source: Internet
Author: User
Tags server installation and configuration


Case:
Web server: domain name www.abc.com IP: 192.168.21.129 China Telecom single line access
Users: Telecom broadband users and mobile broadband users
Problem: telecom users can access www.abc.com normally. Mobile users can access www.abc.com very slowly or even not.
Solution: place a CDN proxy server in the mobile data center. through intelligent DNS resolution, telecom users can directly access the Web server and mobile users can access the CDN proxy server, slow access to Web servers by mobile users
Specific operations:
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
Preparations before installation:
1. Disable SELinux
Vi/etc/selinux/config
# SELINUX = enforcing # comment out
# SELINUXTYPE = targeted # comment out
SELINUX = disabled # Add
: Wq save, close.
Shutdown-r now restart the system


2. After enabling port 80 of the firewall, configure the squid port to 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 # restart the firewall to make the configuration take effect.


3. Modify the host's routing Mode
Vi/etc/sysctl. conf
Net. ipv4.ip _ forward = 1 #0 is disabled, 1 is enabled, use the sysctl-p command to view
System O & M www.osyunwei.com reminder: qihang01 original content©All rights reserved. For more information, see the source and original link.
4. Modify host hosts files and add domain name resolution records
Vi/etc/hosts
192.168.21.129 www.abc.com # Add resolution records


========================================================== ==========================================
Installation started
1. Install Squid
Yum install squid # install (Squid 2.6)
Service squid start # start
Service squid restart # restart
Chkconfig squid on # Set startup


2. Configure Squid
Cp/etc/squid. conf/etc/squid. confbak # backup
Vi/etc/squid. conf # edit the file

Http_port 80 transparent # Set the squid port. The default value is 3128 and the value is 80. You do not need to enter the port number when the client opens the website.
Cache_mem 1024 MB # size of allocated memory
Cache_dir ufs/var/spool/squid 4096 16 256 # Set the cache file size
Cache_inclutive_user squid # Set a user
Cache_paitive_group squid # Set a user group
Access_log/var/log/squid/access. log # Set the access log file
Cache_log/var/log/squid/cache. log # Set the cache log File
Cache_store_log/var/log/squid/store. log # Set cache Record Files
Visible_hostname cdn.abc.com # Set the squid server host name
Cache_mgr root@abc.com # Set administrator mailbox to your own mailbox address)
Acl all src 0.0.0.0/0.0.0.0 # sets the access control list, which is enabled by default.
Http_access allow all # Set the access permission, which is commented out by default
Cache_peer 192.168.21.129 parent 80 0 no-query originserver name = web # When a user accesses the web, Squid sends a request to port 80 of 192.168.21.129
Cache_peer_domain web www.abc.com # Set the web domain name to www.abc.com
Cache_peer_access web allow all # Set access permissions to allow all external clients to access the web

: Wq! # Save and exit
Service squid stop # stop
/Usr/sbin/squid-z # initialize the cache directory
Service squid start # start

Squid Reverse Proxy Server installation and configuration complete
========================================================== ======================================

Enable smart DNS resolution:
If a telecom user accesses the domain www.abc.com and resolves it to 192.168.21.128
If the domain name www.abc.com is accessed by a mobile user, it is resolved to 192.168.21.160.
Use a leased line connection between the CDN cache server and the Web Server

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.