惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

D
DataBreaches.Net
量子位
博客园 - 三生石上(FineUI控件)
Hacker News - Newest:
Hacker News - Newest: "LLM"
月光博客
月光博客
博客园 - 叶小钗
爱范儿
爱范儿
S
SegmentFault 最新的问题
V2EX - 技术
V2EX - 技术
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Security Archives - TechRepublic
Security Archives - TechRepublic
小众软件
小众软件
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
S
Security @ Cisco Blogs
V
Visual Studio Blog
V
V2EX
Schneier on Security
Schneier on Security
Cloudbric
Cloudbric
有赞技术团队
有赞技术团队
C
Check Point Blog
T
Troy Hunt's Blog
Google DeepMind News
Google DeepMind News
Google DeepMind News
Google DeepMind News
TaoSecurity Blog
TaoSecurity Blog
Engineering at Meta
Engineering at Meta
Recent Commits to openclaw:main
Recent Commits to openclaw:main
S
Schneier on Security
N
Netflix TechBlog - Medium
Project Zero
Project Zero
Last Week in AI
Last Week in AI
N
News and Events Feed by Topic
Microsoft Azure Blog
Microsoft Azure Blog
NISL@THU
NISL@THU
T
The Exploit Database - CXSecurity.com
AWS News Blog
AWS News Blog
博客园 - 聂微东
S
Securelist
腾讯CDC
O
OpenAI News
H
Hackread – Cybersecurity News, Data Breaches, AI and More
A
About on SuperTechFans
Microsoft Security Blog
Microsoft Security Blog
B
Blog
博客园 - 【当耐特】
Y
Y Combinator Blog
N
News and Events Feed by Topic
Recorded Future
Recorded Future
Vercel News
Vercel News
PCI Perspectives
PCI Perspectives
Security Latest
Security Latest

博客园 - lodestar

一张图掌握数据存储 使用xtrabackup实现mysql定时热备份 开发篇1:使用原生api和Langchain调用大模型 预热篇2:从RNN到Transformmer 预热篇1:大模型训练显卡选型 macbook安装scala、hadoop、saprk环境 一次linux服务器黑客入侵后处理 linux上搭建svn服务器 Windows系统下Oracle每天自动备份 android中listView的几点总结 使用template method模式简化android列表页面 andorid进度条使用 andorid定时器应用 - lodestar Android网络应用(第一部分) - lodestar 错误数据导致java.lang.IllegalArgumentException:Unsupported configuration attributes 使用ACEGI搭建权限系统:第三部分 acegi安全框架使用:第二部分 使用ACEGI实现权限控制,第一部分 ajax实现用户名存在校验
centos6.5 squid安装
lodestar · 2017-07-12 · via 博客园 - lodestar

squid作用

1正向代理

标准的代理缓冲服务器,须在每一个内部主机的浏览器上明确指明代理服务器的IP地址和端口号。

透明代理缓冲服务器,代理操作对客户端的浏览器是透明的(即不需指明代理服务器的IP和端口)Iptables或者Ipchains实现

2.Squid对架构进行优化,缓存网站,提升web应用访问性能

原理

当squid第一次接受到对特殊资源的请求时,squid经常从原始服务器确认它。假如服务器指示squid的拷贝仍然有效,数据就发送出去。否则,squid升级它的缓存拷贝,并且转发给客户。squid会清除缓存以释放空间给新对象。

工作流程

当代理服务器中客户端需要的数据时:

a. 客户端向代理服务器发送数据请求;

b. 代理服务器检查自己的数据缓存;

c. 代理服务器在缓存中找到了用户想要的数据,取出数据;

d. 代理服务器将从缓存中取得的数据返回给客户端。

当代理服务器中没有客户端需要的数据时:

1. 客户端向代理服务器发送数据请求;

2. 代理服务器检查自己的数据缓存;

3. 代理服务器在缓存中没有找到用户想要的数据;

4. 代理服务器向Internet 上的远端服务器发送数据请求;

5. 远端服务器响应,返回相应的数据;

6. 代理服务器取得远端服务器的数据,返回给客户端,并保留一份到自己的数据缓存中

2.硬件对性能影响

内存和磁盘空间对性能有影响,内存短缺会严重影响性能。更多的磁盘空间意味着更多的缓存目标和更高的命中率。SCSI磁盘比ATA的执行性能好。基本规则是,每G磁盘空间需要32M内存。这样,512M内存的系统,能支持16G的磁盘缓存

Web缓存典型的cache命中率在30%到60%之间

squid安装

操作系统:centos6.5

squid版本:squid-3.1.23-24.el6.x86_64.rpm

3.1检查当前是否安装

rpm -qa squid

3.2 yum方式安装

yum -y install squid

4.配置

4.1安装后目录结构

主程序:

/usr/sbin/squid

脚本:

/etc/init.d/squid

配置文件

/etc/squid/squid.conf

默认访问日志文件:

/var/log/squid/access.log

4.2squid.conf文件配置

vi /etc/squid/squid.conf做如下配置

http_port 192.168.252.11:3164 #监听端口(为了安全起见,在前面加上IP地址,Squid就不会监听外部的网络接口)

cache_dir ufs /var/spool/squid 100 16 256 //定义squid的cache存放路径 cache目录容量100M 一级缓存目录16个,二级缓存目录256个

--一定要在配置文件最下方增加下面这条语句,否则squid无法启动!

visible_hostname localhost

--配置部分ip地址可访问

acl normal src 192.168.101.1-192.168.101.250/32

http_access allow normal

#cache access_log /var/log/squid/access.log 设置访问日志文件

#cache store_log /var/log/squid/store.log 设置网页缓存日志文件

#cache effective user/group squid

5.启动

--创建cache目录

cd /usr/sbin/squid

./squid -z

2017/06/30 15:13:54| Creating Swap Directories

2017/06/30 15:13:54| /var/spool/squid exists

2017/06/30 15:13:54| Making directories in /var/spool/squid/00

2017/06/30 15:13:54| Making directories in /var/spool/squid/01

2017/06/30 15:13:54| Making directories in /var/spool/squid/02

2017/06/30 15:13:54| Making directories in /var/spool/squid/03

2017/06/30 15:13:54| Making directories in /var/spool/squid/04

2017/06/30 15:13:54| Making directories in /var/spool/squid/05

2017/06/30 15:13:54| Making directories in /var/spool/squid/06

2017/06/30 15:13:54| Making directories in /var/spool/squid/07

2017/06/30 15:13:54| Making directories in /var/spool/squid/08

2017/06/30 15:13:54| Making directories in /var/spool/squid/09

2017/06/30 15:13:54| Making directories in /var/spool/squid/0A

2017/06/30 15:13:54| Making directories in /var/spool/squid/0B

2017/06/30 15:13:54| Making directories in /var/spool/squid/0C

2017/06/30 15:13:54| Making directories in /var/spool/squid/0D

2017/06/30 15:13:54| Making directories in /var/spool/squid/0E

2017/06/30 15:13:54| Making directories in /var/spool/squid/0F

iptables对应配置

如果是正常代理需要配置iptables的NAT表,对80端口的访问转发到squid端口

iptables -t nat -A PREROUTING -s 指定ip段 -p tcp --dport 80 -j REDIRECT --to-port 3164

如果是非透明代理需要开发squid的端口

iptables -A INPUT -s 指定ip段 -p tcp --dport 3164 -j ACCEPT

iptables -A OUTPUT -p tcp --dport 3164 -j ACCEP