总体结构:
clientnginx_proxysquidnginx_web
192.168.2.1192.168.2.128192.168.2.133192.168.2.136拓扑图如下
192.168.2.128配置:
yum install nginx -y
vim /etc/nginx/conf.d/default.conf
server {
listen 80 default_server; //指定监听
server_name www.cdbtest.com;//域名访问
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
proxy_pass http://192.168.2.133;//squid服务器IP
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
192.168.2.133配置:
yum install -y squid
vim /etc/squid/squid.conf
http_port 192.168.2.133:80 accel vhost
//侦听本机80端口
cache_peer 192.168.2.136 parent 80 0 originserver /
cache_log /var/log/squid/var/logs/cache.log
//指定日志文件
acl deny_img urlpath_regex -i ^/p_w_picpath
no_cache deny deny_img
//使用acl不缓存源服务器的/usr/share/nginx/html/p_w_picpath下的任何文件
refresh_pattern -i .*.txt$ 43200 100% 43200
对以.txt结尾的文件实行缓存一个月
192.168.2.136 配置 :
yum install nginx -y
vim /etc/nginx/conf.d/default.conf
server {
listen 80 default_server;//侦听本机80端口
listen [::]:80 default_server;//IPV6
server_name www.cdntest.com;//本机域名
root /usr/share/nginx/html; //挂载目录
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
cd /usr/share/nginx/html
mkdir p_w_picpath
//添加text文件和jpg,png等图片文件加入/usr/share/nginx/html/p_w_picpath用于测试
在192.168.2.1上测试一下
在192.168.2.128上curl命令测试jpg图片和text文件
在192.168.2.133上查看squid access.log
在192.168.2.136上查看nginx access.log,没有关于txt的日子
原文链接:https://blog.csdn.net/weixin_31256683/article/details/116711922?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522165934458816781647579220%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fblog.%2522%257D&request_id=165934458816781647579220&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~blog~first_rank_ecpm_v1~times_rank-6-116711922-null-null.nonecase&utm_term=%E8%87%AA%E5%BB%BAcdn
原创文章,作者:优速盾-小U,如若转载,请注明出处:https://www.cdnb.net/bbs/archives/7005