iT邦幫忙

0

Squid + 動態網址的快取設定

最明顯的例子就是防毒軟體的病毒碼更新

以下先用 squid.conf 的部份設定
來呈現何謂動態網址

  1. Avast:

refresh_pattern -i ^http\/:\/\/download[0-9][0-9][0-9]\.avast\.com\/iavs5x\/prod\-ais\.vpx$ 10080 70% 10080 override-expire override-lastmod ignore-no-cache ignore-private ignore-auth
refresh_pattern -i ^http\:\/\/download[0-9][0-9][0-9].avast\.com\/iavs5x\/servers\.def\.vpx$ 10080 70% 10080 override-expire override-lastmod ignore-no-cache ignore-private ignore-auth
refresh_pattern -i ^http\:\/\/download[0-9][0-9][0-9]\.avast\.com\/iavs5x\/part.*.vpx$ 10080 70% 10080 override-expire override-lastmod ignore-no-cache ignore-private ignore-auth
refresh_pattern -i ^http\:\/\/download[0-9][0-9][0-9]\.avast.com\/iavs5x\/jrog.*.vpx$ 10080 70% 10080 override-expire override-lastmod ignore-no-cache ignore-private ignore-auth
refresh_pattern -i ^http\:\/\/download[0-9][0-9][0-9]\.avast\.com\/iavs5x\/vps.*.vpx$ 10080 70% 10080 override-expire override-lastmod ignore-no-cache ignore-private ignore-auth

  1. Avira AntiVir (小紅傘):(目前已知有四個IP,此處僅列舉其二)

refresh_pattern -i ^http\:\/\/62\.146\.66\.178\/update 10080 30% 10080 override-expire override-lastmod ignore-no-cache ignore-private ignore-auth
refresh_pattern -i ^http\:\/\/62\.146\.66\.189\/update 10080 30% 10080 override-expire override-lastmod ignore-no-cache ignore-private ignore-auth

目前這些設定的效果,都是:「任何Client端更新病毒碼,都會透過Squid向原始位址下載」

之前曾觀察過 store.log
病毒碼的更新檔其實都有快取下來
只是因為Client端在執行更新的當下
很容易分到不同載點
所以造成每個Client更新時
都會透過Squid向原始位址下載

所以我想請教的是
對於這類可變動URL的快取
Squid是否有特別的處理方式?

要如何設定才能有「第一台Client透過Squid向原始位址下載完病毒碼後,第二台直接從Squid的快取下載」的效果?

系統環境:CentOS 5.5 + IPTables + Squid-2.7.STABLE9

圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

1 個回答

6
jay0123
iT邦高手 1 級 ‧ 2011-06-01 11:52:58
最佳解答

squid 無法改變目標 ip
用 iptables 做 nat 可改
但 squid 去問後回給 client 也不同
所以我的想法由 Routing table 可試試看
squid Server 只要是往 62.146.66.* 都去 62.146.66.189 問
那對 squid 的 cache 就會相同
不過我用的是 FreeBSD 指令用法如下
route add -net 62.146.66 62.146.66.189
把送往 62.146.66.* 的封包交由 62.146.66.189 轉送

所以請你試試看 CentOS 5.5 的 routing 怎麼做
有問題再討論啦...........

謝謝jay大
我再試試 routing table 的設定
看來得增加好幾組了
之前還曾經看過 80 開頭的 IP

我要發表回答

立即登入回答