Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to build CDN cache server through Squid reverse proxy under linux

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

Most people do not understand the knowledge points of this article "how to build CDN cache server through Squid reverse proxy under linux", so the editor summarizes the following contents, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this article "how to build CDN cache server through Squid reverse proxy under linux".

Case study:

Web server: domain name www.abc.com ip:192.168.21.129 telecom single line access

Access users: telecom broadband users, mobile broadband users

There is a problem: it is normal for telecom users to open www.abc.com, while mobile users are slow to open www.abc.com, even unable to open it.

Solution: put a cdn proxy server in the mobile computer room, through intelligent dns parsing, let telecom users directly access the web server, let mobile users access the cdn proxy server, and solve the problem that mobile users are slow to access the web server.

Specific operations:

Cdn proxy server:

System: centos 5.5.Hostname: cdn.abc.com ip:192.168.21.160 install squid software, configure reverse proxy to build cdn cache server

Prepare before installation:

1. Close selinux

Vi / etc/selinux/config

# selinux=enforcing # comment out

# selinuxtype=targeted # comment out

Selinux=disabled # increased

: wq save, close.

Shutdown-r now restart the system

2. Open firewall port 80 (the port behind the configuration of squid is 80)

Vi / etc/sysconfig/iptables

Add the following

-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 for the configuration to take effect

3. Modify the route pattern of the host

Vi / etc/sysctl.conf

Net.ipv4.ip_forward = 1 # 0: off, 1: sysctl-p to enable routing.

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 start

1. Install squid

Yum install squid # installation (squid 2.6)

Service squid start # Startup

Service squid restart # restart

Chkconfig squid on # set boot up

2. Configure squid

Cp / etc/squid/squid.conf / etc/squid/squid.confbak # backup

Vi / etc/squid/squid.conf # edit file

Http_port 80 transparent # sets the squid port, which defaults to 3128 and is set to 80. The client does not need to enter the port number when opening the website.

Cache_mem 1024 mb # allocated memory size

Cache_dir ufs / var/spool/squid 4096 16 256 # set cache file size

Cache_effective_user squid # set up users

Cache_effective_group squid # set up user groups

Access_log / var/log/squid/access.log # sets the access log file

Cache_log / var/log/squid/cache.log # sets cache log files

Cache_store_log / var/log/squid/store.log # sets the cache record file

Visible_hostname cdn.abc.com # set the squid server hostname

Cache_mgr root@abc.com # set the administrator mailbox (set to your own email address)

Acl all src 0.0.0.0amp 0.0.0.0 # sets the access control list, which is enabled by default

Http_access allow all # sets access permissions, which are commented out by default

Cache_peer 192.168.21.129 parent 800 no-query originserver name=web # when a user accesses 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 # sets access permissions to allow all external clients to access web

: wq! # Save exit

Service squid stop # stop

/ usr/sbin/squid-z # initialize the cache cache directory

Service squid start # Startup

Squid reverse proxy server installation and configuration complete

=

Enable intelligent dns parsing:

If the telecom user accesses the domain name www.abc.com to 192.168.21.128

If the mobile user accesses the domain name www.abc.com to 192.168.21.160

A dedicated line connection is used between the cdn cache server and the web server

The above is about the content of this article on "how to build a CDN cache server through Squid reverse proxy under linux". I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report