Squid
Squid反向代理
http_access allow all
允许所有主机
配置监听端口以及后端服务器
http_port 80 accel defaultsite=192.168.130.100 cache_peer 192.168.130.100 parent 8080 0 no-query originserver cache_mem 256 MB cache_dir ufs /var/spool/squid 100 16 256 |
后边的数字分别表示:缓存大小(MB)、一级目录数、二级目录数
squid.conf
http_access allow all https_port 443 accel cert=ca.crt key=ca.key |
accel
加速器/反向代理模式
cache_peer 10.30.40 parent 443 0 originserver ssl sslflags=DONT_VERIFY_PEER name=nets weight=5 max-conn=35 |
例子:
| hostname | type | proxy-port | icp-port | options |
cache_peer | cdn.example.com | parent | 3128 | 3130 | default |
cache_peer | example.com | parent | 3128 | 3130 | default |
cache_peer | 192.168.1.100 | sibling | 80 | 0 | proxy-only |
cache_peer | 10.30.40.250 | sibling | 80 | 0 | proxy-only |
type
对等机类型有以下三种:
parent 父亲--父级
sibling 兄弟姐妹--同级
multicast 组播
proxy-port
对等机接受的端口号,对于其他代理服务器,这里通常是3128,对于web服务器这里是80
icp-port
配置CDN之间的端口,一般对等机不支持ICP或HTCP,设置为0。
options
no-query
禁用对此邻居的ICP查询。
proxy-only
仅仅代理模式,从对等机获取对象不会存储在本地
default
这是一个父缓存,优先使用其他缓存,当找不到任何对等机,则使用这一个。当指定多次,仅使用第一个。
originserver
使此父级作为源服务器联系。用于对等服务器为Web服务器时的加速器设置。
ssl
使用SSL/TLS与对等机连接
sslflags=...
DONT_VERIFY_PEER
即使证书无法验证,也要接受证书。
name=xx
对等机的唯一名称
weight=N
权值,默认为1,越大越优先
max-conn=N
限制Squid向该对等机打开的并发连接数
请求转发
从客户端过来的请求,如果是 blog.local.com,则Squid向a发送请求
如果是 admin.local.com static.local.com ,则Squid向b的端口80发送请求
cache_peer 192.168.22.21 parent 80 0 no-query originserver weight=3 name=a cache_peer 192.168.22.24 parent 80 0 no-query originserver weight=2 name=b
cache_peer_domain a blog.local.com cache_peer_domain b admin.local.com static.local.com |