交 通 大 學 計 算 機 中 心 陳 昌 盛 e-mail: [email protected]

73
1 交 交 E-mail: [email protected] WWW Proxy/Cache 交交交 交交交交交 TANet Web-proxy Tutorial Course, 88.05.14

Upload: faith

Post on 15-Jan-2016

202 views

Category:

Documents


0 download

DESCRIPTION

WWW Proxy/Cache 系統的 建置與管理. 交 通 大 學 計 算 機 中 心 陳 昌 盛 E-mail: [email protected]. TANet Web-proxy Tutorial Course, 88.05.14. 課程大綱. WWW Proxy/Caching 系統簡介 ( p3-p23) Squid 2.x 的建置與設定 ( p23-p44) 其他相關的系統管理課題 ( p45-p53) 附錄 ( p54-). 相關的資訊來源. 相關網站 - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: 交  通  大  學 計  算  機  中  心 陳  昌  盛 E-mail: cschen@cc.nctu.tw

1

交 通 大 學 計 算 機 中 心陳 昌 盛

E-mail: [email protected]

WWW Proxy/Cache 系統的建置與管理

TANet Web-proxy Tutorial Course, 88.05.14

Page 2: 交  通  大  學 計  算  機  中  心 陳  昌  盛 E-mail: cschen@cc.nctu.tw

2

WWW Proxy/Caching 系統簡介 (p3-p23)

Squid 2.x 的建置與設定 (p23-p44)其他相關的系統管理課題 (p45-p53)附錄 (p54-)

課程大綱

Page 3: 交  通  大  學 計  算  機  中  心 陳  昌  盛 E-mail: cschen@cc.nctu.tw

3

• 相關網站– http://www.auth.gr/Squid/ ( squid home page)– http://cache.is.co.za (squid.conf 設定檔 )– http://squid.nlanr.net ( FAQ)– http://proxy.nctu.edu.tw

• RFC 1016, 2186, 2187

• Mailing List– [email protected]– http://proxy.nctu.edu.tw/mailing

相關的資訊來源

Page 4: 交  通  大  學 計  算  機  中  心 陳  昌  盛 E-mail: cschen@cc.nctu.tw

4

WWW Proxy 系統簡介• Web Proxy/Caching 介紹• TANet 骨幹頻寬分割使用 ( 24M bps)

– 163.28.0.0 server 專用 channel ( 16M bps )

• 關於 Squid

Page 5: 交  通  大  學 計  算  機  中  心 陳  昌  盛 E-mail: cschen@cc.nctu.tw

5

Web Caching - 基礎篇• 什麼是 web caching ?

– 什麼是 browser caching– 什麼是 proxy caching ?

• Transparent Proxy

• http accelerator vs proxy/caching– accelerator : 加快 remote 取 local 資料– caching : 加快 local 取 remote 資料

• Redirector – 改寫 URL, 管制連線對象

Page 6: 交  通  大  學 計  算  機  中  心 陳  昌  盛 E-mail: cschen@cc.nctu.tw

6

Web caching server 運作基本觀念

• Web caching 的基本運作原理– hit: 文件檔在 cache 中– miss: 文件檔不在 cache 中– refresh_hit, refresh_miss

• positive caching vs negative caching

Page 7: 交  通  大  學 計  算  機  中  心 陳  昌  盛 E-mail: cschen@cc.nctu.tw

7

Web caching 相關 protocol 的運作

• TCP connection 的使用時機– browsers/cache 到另一個 web server 或

cache 取回資料• UDP connection 的使用時機

– 某一 cache server 用以 , 查詢其他的 neighbor cache , 有無一筆該站想要的資訊

– ICP query ( index 資料 )

Page 8: 交  通  大  學 計  算  機  中  心 陳  昌  盛 E-mail: cschen@cc.nctu.tw

8

Proxy/caching server

HDcache

PC client

Internet

Fig. 1 Proxy/caching server 運作示意圖

• TANet TANet 區域網路使用者區域網路使用者

• 163.28.xxx.yyy

TANet Gateway

X

1a

2a

1b

2b

3b

4b

Page 9: 交  通  大  學 計  算  機  中  心 陳  昌  盛 E-mail: cschen@cc.nctu.tw

9

電子期刊等專用Proxy server

PC client

Internet

Fig. 2 電子期刊專用 Proxy server 運作圖

• 限制使用對象 限制使用對象 (( 必須註冊必須註冊 ))

163.28.xxx.yyy

TANet Gateway

• No Cache allowed

Page 10: 交  通  大  學 計  算  機  中  心 陳  昌  盛 E-mail: cschen@cc.nctu.tw

10

HDcache

Internet

Fig. 3 Transparent Proxy/caching 運作示意圖

TANet Gateway

Proxy

PC client

1

2

3

4

5

6

7b

7a Router/Layer4 SW

Page 11: 交  通  大  學 計  算  機  中  心 陳  昌  盛 E-mail: cschen@cc.nctu.tw

11

httpdaccelerator

HDcache

Local www server

Internet

Fig. 4 www accelerator server 運作圖• Redirector on 163.28.xxx.yyy

TANet Gateway1a

1b

2a

2c

2b

1c

Port 80•Inside firewall

Page 12: 交  通  大  學 計  算  機  中  心 陳  昌  盛 E-mail: cschen@cc.nctu.tw

12

Proxy Cache Metric ( 參考數字 )

• From IRCACHE project– Hit ratio (25% - 30%)– byte hit ratio ( 20%, 通常低於前一項 )– http://www.ircache.net/

• NCTU Proxy network– Hit ratio ( 30%-35%)– byte hit ratio ( 60%-70%)– http://proxy.nctu.edu.tw/– http://www.edu.tw/moecc/index.htm ( 選文宣刊物 )

Page 13: 交  通  大  學 計  算  機  中  心 陳  昌  盛 E-mail: cschen@cc.nctu.tw

13Fig.5 Proxy.NCTU.edu.tw 的使用情況 (1998/11/27)

(T)

(P)

(C)

Page 14: 交  通  大  學 計  算  機  中  心 陳  昌  盛 E-mail: cschen@cc.nctu.tw

14

全球 Proxy Cache 網路架構• 美國 NLANR 的 IRCACHE 網路

– http://www.ircache.net– 其他各地 , 可以從上面網頁連上

• 臺灣地區 proxy cache 網路– http://cache.sinica.edu.tw/cache/index.html

Page 15: 交  通  大  學 計  算  機  中  心 陳  昌  盛 E-mail: cschen@cc.nctu.tw

15

Fig.6 IRCACHE 的架構 , from http://www.ircache.net

Page 16: 交  通  大  學 計  算  機  中  心 陳  昌  盛 E-mail: cschen@cc.nctu.tw

16

Proxy-NCTU

Internet

MOE

Proxy-N

Fig. 7 TANet 骨幹的 Proxy Network ( 163.28.0.0 )

TANet gateway

Page 17: 交  通  大  學 計  算  機  中  心 陳  昌  盛 E-mail: cschen@cc.nctu.tw

17

Squid Cache Hierarchy

• Parent/child cache– parent 靠近網路骨幹 , child 在較偏遠端– parent 替 child 解決 cache miss

• siblings ( 同一層 --> 原意 , 兄弟姐妹 )– siblings 相互支援 ( loading 分攤 )– 有一套固定的運作方式 ( 下一頁 )

Page 18: 交  通  大  學 計  算  機  中  心 陳  昌  盛 E-mail: cschen@cc.nctu.tw

18

Squid Cache Resolution Algorithm

• Send ICP queries to all appropriate siblings • Wait for all replies to arrive with a configurable

timeout (the default is two seconds). • Begin fetching the object upon receipt of the first

HIT reply, or • Fetch the object from the first parent which replied

with MISS (subject to weighting values), or • Fetch the object from the source

Page 19: 交  通  大  學 計  算  機  中  心 陳  昌  盛 E-mail: cschen@cc.nctu.tw

19

Proxy server HD

cache

Internet

Fig. 8 Proxy/caching 與 DNS server 搭配 運作圖

• 163.28.xxx.yyy

TANet Gateway

DNS server

PC client

1

2

3a

3b 4 5

6a

6b

Page 20: 交  通  大  學 計  算  機  中  心 陳  昌  盛 E-mail: cschen@cc.nctu.tw

20

What is Squid ? (1)

• Squid 從美國的 Harvest 計劃而來 (ARPA 支援 ).

• Squid 是一個高效能的 proxy caching server 系統軟體

• supporting FTP, gopher, and HTTP data objects• Squid handles all requests in a single, non-

blocking, I/O-driven process.

Page 21: 交  通  大  學 計  算  機  中  心 陳  昌  盛 E-mail: cschen@cc.nctu.tw

21

What is Squid ? (2)

• Squid supports SSL, extensive access controls, and full request logging.

• 使用 ICP 通信協定 ( Internet Cache Protocol)

• squid caches 可以安排成階層式 (hierarchy) 或 網狀 (mesh) 的網路 .

Page 22: 交  通  大  學 計  算  機  中  心 陳  昌  盛 E-mail: cschen@cc.nctu.tw

22

What is Squid ? (3)

• Squid keeps meta data and especially hot objects cached in RAM

• caches DNS lookups, supports non-blocking DNS lookups,

• and implements negative caching of failed requests.

Page 23: 交  通  大  學 計  算  機  中  心 陳  昌  盛 E-mail: cschen@cc.nctu.tw

23

Proxy 系統的建置與管理• Proxy server 選定與安裝• Cache hierarchy ( neighbor sites )

• Access control

• Gateway program ( Gopher, Ftp, …)

• Cache administration & Expiration – Cache 存放空間的管理

• 系統記錄與製做統計報告

Page 24: 交  通  大  學 計  算  機  中  心 陳  昌  盛 E-mail: cschen@cc.nctu.tw

24

WWW Proxy server 的規畫

• WWW Proxy server 的規畫– Memory, Disk, Network, CPU, UPS system

• 最重要的系統資源是主記憶體 (physical memory).

• 硬碟系統 (disk), 通常是系統主要效能的瓶頸 .

Page 25: 交  通  大  學 計  算  機  中  心 陳  昌  盛 E-mail: cschen@cc.nctu.tw

25

NCTU Proxy server 的規畫• Hardware( 3 套 )

– 300 Mhz Pentium II CPU

– 512MB RAM

– 10 * 4GB UW-SCSI ( IBM )• 共約 120 GB

– 100M Network Interface Card ( Intel )

• Software– FreeBSD-2.2.8-stable

– squid 2.2

Page 26: 交  通  大  學 計  算  機  中  心 陳  昌  盛 E-mail: cschen@cc.nctu.tw

26

取得 Proxy server Squid 軟體• Squid software 的取得

– ftp://squid.nlanr.net ( 原始站 )– ftp://ftp.nctu.edu.tw/WWW/Proxy/Squid/squid-2/*

• Squid Server 的安裝– FAQ

• http://www.auth.gr/Squid/FAQ/FAQ.html

– User Guide

• http://www.auth.gr/SquidUsers/

Page 27: 交  通  大  學 計  算  機  中  心 陳  昌  盛 E-mail: cschen@cc.nctu.tw

27

Squid 2.x 的組成• Squid - 主要 server 程式• dnsserver - 外掛的 DNS 查詢程式 • 附帶的管理與用戶單連線工具程式

Page 28: 交  通  大  學 計  算  機  中  心 陳  昌  盛 E-mail: cschen@cc.nctu.tw

28

Squid-2 的建置與設定• Getting and Compiling Squid

% tar xzf squid-2.2-src.tar.gz

% cd squid-2.2.RELEASE

% ./configure --prefix=/home/squid

% make

Page 29: 交  通  大  學 計  算  機  中  心 陳  昌  盛 E-mail: cschen@cc.nctu.tw

29

Squid 中典型的系統目錄• 範例 ( /home/squid/ )

– bin, cgi-bin, etc, logs, scripts– 主要設定檔安置目錄 ( /home/squid/etc/* )

• squid.conf, mime.conf, mib.txt, icons/*, errors/*

– 系統記錄檔存放目錄 ( /home/squid/logs/* )

• access.log, cache.log, ...

• Squid port – http_port : 3128

– icp_port: 3130

Page 30: 交  通  大  學 計  算  機  中  心 陳  昌  盛 E-mail: cschen@cc.nctu.tw

30

How do I start Squid 2.x ?

• 編輯 squid.conf

• /usr/local/squid/bin/squid -z– 首先將 cache swap 目錄造出來

• /usr/local/squid/bin/RunCache &– 執行 RunCache 這個批次檔 , 開始啟動

squid 這一組程式

Page 31: 交  通  大  學 計  算  機  中  心 陳  昌  盛 E-mail: cschen@cc.nctu.tw

31

Squid.conf 設定的項目分類 (1)

• 網路相關的設定選項• 影響 “ neighbor 選擇法則” 運作的選項• 影響 cache size 設定的選項• 記錄檔 (log) 路徑名稱與 cache directors• “ 外部支援程式“相關的選項• 調整 (tuning) caching 效能的選項 • timeouts

Page 32: 交  通  大  學 計  算  機  中  心 陳  昌  盛 E-mail: cschen@cc.nctu.tw

32

Squid.conf 的設定項目分類 (2)

• 存取管制 (Access control)• Proxy 系統管理 (Administrative parameters)• Options for the cache registration service• httpd-accelerator options• 其它雜項設定 (Miscellaneous)• 限制各別站臺的使用頻寬 (Delay Pool

parameters )

Page 33: 交  通  大  學 計  算  機  中  心 陳  昌  盛 E-mail: cschen@cc.nctu.tw

33

Squid 的功能 , 補充說明 • Ipcache, FQDNcache

– Ipcache: Hostname to IP-Number mapping

– FQDNCache : IP-Number to Hostname mapping

• Cache Digest ( 2.x )– a summary of the contents of an Internet Object

Caching Server– an indication of whether or not particular URLs

are in the cache• X-Forwarded-For

– X-Forwarded-For: 128.138.243.150, unknown, 192.52.106.30

Page 34: 交  通  大  學 計  算  機  中  心 陳  昌  盛 E-mail: cschen@cc.nctu.tw

34

Squid.conf 中 , 需要定義的參數 - “proxy.nctu.edu.tw” 上的實例

• 大多數的參數使用內定值 (default )– 底下就列出需要重新定義者

• Cache_peer proxy.edu.tw sibling 3128 3130 no-netdb-exchange

• cache_mem 128M– cache_swap_low 93– cache_swap_high 95– cache_mem_low 90– cache_mem_high 95

• maximum_object_size 16384 KB

Page 35: 交  通  大  學 計  算  機  中  心 陳  昌  盛 E-mail: cschen@cc.nctu.tw

35

Squid.conf (cont.)

• ipcache_size 20480 ( hostname --> IP addr. )– ipcache_low 90– ipcache_high 95

• fqdnsize 20480 ( IP addr ---> FQDN )

• cache_dir ( 可以再加 )– cache_dir /home/squid/cache 100 16 256– cache_dir /da1s1e 4000 32 32

• logfile_rotate 10

Page 36: 交  通  大  學 計  算  機  中  心 陳  昌  盛 E-mail: cschen@cc.nctu.tw

36

增建一個 cache directory (Squid.conf)

• 增建某一個 cache directory 的程序– 編輯 squid.conf, 增加一筆 cache_dir 項目行– 將該 directory 初始化 , 執行

• # squid -z

– 通知 Squid 重新分配  cache 的分佈 , 執行 • # squid -k reconfigure

• 不必停掉執行中的  squid 程式

Page 37: 交  通  大  學 計  算  機  中  心 陳  昌  盛 E-mail: cschen@cc.nctu.tw

37

移除某一個 cache directory(Squid.conf)

• 移除某一個  cache directory– 編輯 squid.conf, 刪掉該筆 cache_dir 項目行– 將執行中的 squid 重新執行 (shutdown and

restart)• # squid -k shutdown

• # 重新執行 squid ( 使用 RunCache 會自動重跑 )

– 刪除原系統中 , 已不用的 cache directory

• 必須中斷執行中的  squid 程式

Page 38: 交  通  大  學 計  算  機  中  心 陳  昌  盛 E-mail: cschen@cc.nctu.tw

38

不想 cache 臨近地區的 data (squid.conf)

• 使用 no_cache 這個選項功能• 編輯 squid.conf ( squid-2)

– 範例 1 ( IP address)• acl Local dst 140.113.0.0/16

• no_cache deny Local

– 範例 2( domain name)• acl Local_D dstdomain edu.tw

• no_cache deny Local_D

Page 39: 交  通  大  學 計  算  機  中  心 陳  昌  盛 E-mail: cschen@cc.nctu.tw

39

Squid cache replacement algorithm

• LRU (Least Recent Used) 是最基本原則– Low water mark (90%), High water mark(95%)

• 優先移除者– negative cached, private key– 最後一次存取時間超過 LRU 的期限 (threshold)

• 不可移除者– 有其他用戶正需求這一個檔– 正從上游站 , 取過來的檔

Page 40: 交  通  大  學 計  算  機  中  心 陳  昌  盛 E-mail: cschen@cc.nctu.tw

40

關於 Access Control 的設定• acl, http_access, icp_access

• allow/deny

• And/Or Logics– All elements of an acl entry are OR'ed together. – All elements of an access entry are AND'ed

together. e.g. http_access and icp_access.

• src/srcdomain, dst/dstdomain

Page 41: 交  通  大  學 計  算  機  中  心 陳  昌  盛 E-mail: cschen@cc.nctu.tw

41

squid.conf (cont.)- access control [1]

• 設立 Cache Manager– acl manager proto cache_object– acl localhost src 127.0.0.1/255.255.255.255– acl Proxy src proxy.nctu.edu.tw proxy2.nctu.edu.tw

proxy3.nctu.edu.tw– acl purge method purge– acl FTP proto FTP– acl all src 0.0.0.0/0.0.0.0

Page 42: 交  通  大  學 計  算  機  中  心 陳  昌  盛 E-mail: cschen@cc.nctu.tw

42

squid.conf (cont.)- access control [2]

• acl twdn dstdomain tw twnic.net hinet.net acer.net wownet.net seeder.net silkera.net neto.net timenet.net tw.aunet.net

• acl TANet src 163.28.0.0/16 proxy.thu.edu.tw • acl HCdn srcdomain nthu.edu.tw nchc.gov.tw srrc.gov.tw

chu.edu.tw nhctc.edu.tw hceb.edu.tw hc.edu.tw hcc.edu.tw cic.edu.tw mhit.edu.tw firdi.org.tw hchcc.gov.tw lctc.edu.tw ymit.edu.tw chinmin.edu.tw thctc.edu.tw

Page 43: 交  通  大  學 計  算  機  中  心 陳  昌  盛 E-mail: cschen@cc.nctu.tw

43

squid.conf (cont.)- access control (3)

• Http_access– http_access allow manager Proxy– http_access deny manager– …– http_access deny all

• icp_access– icp_access allow TANet

– ….

– icp_access deny all

Page 44: 交  通  大  學 計  算  機  中  心 陳  昌  盛 E-mail: cschen@cc.nctu.tw

44

ACL ban list ( 管制 )• 範例 1 ( 找 keyword, 用 regular expression)

– acl Cooking1 url_regex cooking– acl Recipe1 url_regex recipe– http_access deny Cooking1– http_access deny Recipe1– http_access allow all

• 範例 2 ( 用 domain name)– acl Cooking2 dstdomain gourmet-chef.com– http_access deny Cooking2– http_access allow all

Page 45: 交  通  大  學 計  算  機  中  心 陳  昌  盛 E-mail: cschen@cc.nctu.tw

45

Syslog maintenance

• /home/squid/etc/squid.conf– logfile_rotate 3

• Crontab entry for log-rotate – 0 0 * * * /bin/kill -USR1 `cat /home/squid/logs/squid.pid`

• 每天執行一次 , 以避免記錄檔越來越大 , 無法處理

Page 46: 交  通  大  學 計  算  機  中  心 陳  昌  盛 E-mail: cschen@cc.nctu.tw

46

相關管理的工具程式• wget

• <ping, traceroute, nslookup> on proxy server homepage

• cache manager CGI ( cachemgr.cgi)– 使用 Apache 為例– srm.conf, squid.conf, access.conf

• auto-proxy configuration support

Page 47: 交  通  大  學 計  算  機  中  心 陳  昌  盛 E-mail: cschen@cc.nctu.tw

47

設定 Cache Manager ( Apache)- 參考 FAQ 9.1 - 9.9

• /home/squid/etc/srm.confScriptAlias /Squid/cgi-bin/ /home/squid/cgi-bin

• /home/squid/etc/access.conf< Location /Squid/cgi-bin/cachemgr.cgi>order deny,allowdeny form allallow from proxy.nctu.edu.tw,proxy2.nctu.edu.tw</Location>

Page 48: 交  通  大  學 計  算  機  中  心 陳  昌  盛 E-mail: cschen@cc.nctu.tw

48

設定 Cache Manager ( Apache)

- 參考 FAQ 9.1 - 9.9 (cont.)

• /home/squid/etc/squid.confacl manager proto cache_object

acl localhost srt 127.0.0.1/255.255.255.255

acl all src 0.0.0.0/0.0.0.0

#

http_access deny manager !localhost

http_access allow all

Page 49: 交  通  大  學 計  算  機  中  心 陳  昌  盛 E-mail: cschen@cc.nctu.tw

49

Sample - access.log(1)

912355210.560 10097 super.Dorm9.NCTU.edu.tw TCP_MISS/000 0 GET http://adforce.i

mgis.com/? - DIRECT/adforce.imgis.com -

912355210.712 0 ccproxy.nsysu.edu.tw UDP_MISS/000 76 ICP_QUERY http://lygo.

com/ly/p/bandn/thumbnails/9780553574753.gif - NONE/- -

912355210.712 0 w3-gate2.ntu.edu.tw UDP_DENIED/000 82 ICP_QUERY http://www.

tvb.com.hk/drama/image/home/top_link/newsong_d.gif - NONE/- -

912355210.712 0 proxy.ncku.edu.tw UDP_HIT/000 70 ICP_QUERY http://www.penth

ousemag.com/reading/images/c3.gif - NONE/- -

912355210.718 10171 proxy.nthu.edu.tw TCP_REFRESH_HIT/304 265 GET http://www.be

seen.com/ads/r03_howlow.gif - DIRECT/www.beseen.com -

912355211.482 358 bill.Dorm-GD1.NCTU.edu.tw TCP_HIT/200 1762 GET http://www.j

girls.com/jconsole/index.html - NONE/- text/html

912355211.482 358 hilbert.Dorm-GD1.NCTU.edu.tw TCP_IMS_HIT/304 225 GET http:/

/www.bannersolutions.com/images/ad_info.gif - NONE/- image/gif

Page 50: 交  通  大  學 計  算  機  中  心 陳  昌  盛 E-mail: cschen@cc.nctu.tw

50

Sample -cache.log

1998/11/30 06:10:34| Starting Squid Cache version 2.1.PATCH1 for i386-unknown-freebsd2.2.7...

1998/11/30 06:10:34| Process ID 18654

1998/11/30 06:10:34| With 1024 file descriptors available

1998/11/30 06:10:34| Performing DNS Tests...

1998/11/30 06:10:34| Successful DNS name lookup tests...

1998/11/30 06:10:34| helperOpenServers: Starting 20 'dnsserver' processes

1998/11/30 06:10:34| Unlinkd pipe opened on FD 29

1998/11/30 06:10:34| Swap maxSize 32768000 KB, estimated 1638400 objects

1998/11/30 06:10:34| Target number of buckets: 40960

1998/11/30 06:10:34| Using 65536 Store buckets, replacement runs every 1 second

1998/11/30 06:10:34| Max Mem size: 131072 KB

1998/11/30 06:10:34| Max Swap size: 32768000 KB

1998/11/30 06:10:34| Store logging disabled

1998/11/30 06:10:34| Rebuilding storage in Cache Dir #0 (CLEAN)

Page 51: 交  通  大  學 計  算  機  中  心 陳  昌  盛 E-mail: cschen@cc.nctu.tw

51

Sample -cache.log (2)

1998/11/30 06:10:34| Rebuilding storage in Cache Dir #7 (CLEAN)

1998/11/30 06:10:34| Loaded Icons.

1998/11/30 06:10:35| Accepting HTTP connections on port 3128, FD 65.

1998/11/30 06:10:35| Accepting ICP messages on port 3130, FD 66.

1998/11/30 06:10:35| Accepting SNMP messages on port 3401, FD 67.

1998/11/30 06:10:35| Ready to serve requests.

1998/11/30 06:10:35| Configuring Sibling proxy.edu.tw/3128/3130

1998/11/30 06:10:35| Configuring Sibling w3-gate2.ntu.edu.tw/3128/3130

1998/11/30 06:10:35| Configuring Sibling proxytest.ncu.edu.tw/3128/3130

1998/11/30 06:10:35| Configuring Sibling cache.nchu.edu.tw/3128/3130

1998/11/30 06:10:35| Configuring Sibling proxy.ccu.edu.tw/3128/3130

1998/11/30 06:10:35| Configuring Sibling gate.ncku.edu.tw/3128/3130

1998/11/30 06:10:35| Configuring Sibling ccproxy.nsysu.edu.tw/3128/3130

1998/11/30 06:10:36| 65536 Entries read so far.

Page 52: 交  通  大  學 計  算  機  中  心 陳  昌  盛 E-mail: cschen@cc.nctu.tw

52

Sample -cache.log (3)

1998/11/30 06:45:13| Detected DEAD Sibling: proxytest.ncu.edu.tw/3128/3130

1998/11/30 06:45:13| Detected REVIVED Sibling: proxytest.ncu.edu.tw/3128/3130

1998/11/30 06:47:07| clientIfRangeMatch: Weak ETags are not allowed in If-Range:

"b406e-5b6-36279831" ? "b406e-5b6-36279831”

1998/11/30 06:50:48| internalStart: unknown request:

GET /squid-internal-periodic/store_digest HTTP/1.0

Accept: application/cache-digest

Accccept: text/html

Via: 0.0 ccproxy.nsysu.edu.tw:3128 (Squid/2.1.PATCH1)

X-Forwarded-For: unknown

Host: w3-gate.nctu.edu.tw:3128

Cache-Control: max-age=1209600

Connection: keep-alive

Page 53: 交  通  大  學 計  算  機  中  心 陳  昌  盛 E-mail: cschen@cc.nctu.tw

53

Sample -cache.log (4)

1998/11/30 08:13:49| urlParse: URI has whitespace: {http://www.hotwired.com/spec

ial/modx/news.gif?p_uniqid=1cKL7P4NYBCC9vptmA; s_uniqid=2Em4/MoNZkfAd4vndA}

1998/11/30 08:14:01| urlParse: URI has whitespace: {http://www.hotwired.com/spec

ial/modx/news.gif?p_uniqid=1cKL7P4NYBCC9vptmA; s_uniqid=2Em4/MoNZkfAd4vndA}

1998/11/30 08:14:10| clientSendMoreData: Deferring http://ads03.focalink.com/Sma

rtBanner/nph-graphic/14345.2

1998/11/30 08:14:10| clientKeepaliveNextRequest: FD 107 Sending next

1998/11/30 08:14:14| urlParse: URI has whitespace: {http://www.hotwired.com/spec

ial/modx/news.gif?p_uniqid=1cKL7P4NYBCC9vptmA; s_uniqid=2Em4/MoNZkfAd4vndA}

1998/11/30 08:19:52| urlParse: URI has whitespace: {http://www.symantec.com/regi

on/tw/graphics/tw_wfx_box_sm.jpg WIDTH=}

1998/11/30 08:19:53| urlParse: URI has whitespace: {http://www.symantec.com/regi

on/tw/graphics/tw_pca_box_sm.jpg WIDTH=}

1998/11/30 08:23:28| Detected DEAD Sibling: proxy.edu.tw/3128/3130

1998/11/30 08:23:30| Detected REVIVED Sibling: proxy.edu.tw/3128/3130

Page 54: 交  通  大  學 計  算  機  中  心 陳  昌  盛 E-mail: cschen@cc.nctu.tw

54

附錄• Transparent Proxy 的設定• HTTP Accelerator 設定範例• http://proxy.nctu.edu.tw

– 如何使用交通大學 Proxy 服務– Proxy.nctu.edu.tw 使用量分佈統計

• Cache Manager 的 Sample

Page 55: 交  通  大  學 計  算  機  中  心 陳  昌  盛 E-mail: cschen@cc.nctu.tw

55

Transparent Proxy (Squid 設定 )

• 讓 transparent proxy 運作的三道程序– 將 packets 導到 proxy/cache host

• 透過 router, layer4 switch

– 讓你的 cache host 接受這些經過重導的packet, 並轉送到機器上的 proxy/cache 程式

• ipfwdadm(Linux), ipnat/ip-filter(FreeBSD & Others)

– 設定 squid 認下這一些 packet, 並找出目的地 address

Page 56: 交  通  大  學 計  算  機  中  心 陳  昌  盛 E-mail: cschen@cc.nctu.tw

56

Squid 當 HTTP Accelerator 的範例• 範例 1

– http_port 80– httpd_accel_host localhost– httpd_accel_port 81– httpd_accel_with_proxy on

• 這一行的作用 , 同時當 proxy, accelerator

• 範例 2:– http_port 80– httpd_accel_host otherhost.foo.com– httpd_accel_port 80

Page 57: 交  通  大  學 計  算  機  中  心 陳  昌  盛 E-mail: cschen@cc.nctu.tw

57

如何使用交通大學 Proxy 服務- http://proxy.nctu.edu.tw

• Proxy 相關資訊– 使用須知 – 一般使用者設定方法 ( user 端配合設定 )

– 其它區網中心與上游的 Proxy (acl 與 cache 設定 )

– 新竹地區各單位 Proxy (acl 與 cache 設定 )

Page 58: 交  通  大  學 計  算  機  中  心 陳  昌  盛 E-mail: cschen@cc.nctu.tw

58

選擇適合的 Auto Proxy Configuration

• 由於網路架構的不同,以及為了 reliability 的考量,交通大學校內與校外單位所使用的設定檔並不相同,我們同時提供數份相同的 Auto Proxy 設定檔,請選擇正確的設定檔。

• 外校單位(清華、中央、工研院等)– http://nctu.edu.tw/proxy.pac

– http://proxy.nctu.edu.tw/proxy.pac

– http://proxy2.nctu.edu.tw/proxy.pac

• 交通大學校內– http://nctu.edu.tw/nctu.pac

– http://proxy.nctu.edu.tw/nctu.pac

– http://proxy2.nctu.edu.tw/nctu.pac

Page 59: 交  通  大  學 計  算  機  中  心 陳  昌  盛 E-mail: cschen@cc.nctu.tw

59

如何設定 Auto Proxy Configuration

• MSIE 4.x – 檢視 -> Internet 選項 -> 連線 -> 自動組態 -> 組態– 然後在 URL 的地方填入 Auto Proxy URL, 並按 Reload 後,即可使用

• Netscape 4.06+– Edit -> Preferences -> Advanced -> Proxies-> Automatic Proxy

Configuration

– 然後在 URL 的地方填入 Auto Proxy URL, 並按 Reload 後,即可使用

Page 60: 交  通  大  學 計  算  機  中  心 陳  昌  盛 E-mail: cschen@cc.nctu.tw

60

如何加入一個 cache hierarchy/mesh ?- squid 2.x

• 在 2.x 的 squid.conf 中 , 使用 cache_peer 這個 directive 來分別指定 parent( 上一層 ) or sibling( 同一層 ) 的結點

• 這裏以 proxy.nctu.edu.tw 給新竹區網下其他單位cache_peer w3-gate.nctu.edu.tw parent 3128 3130 no-query no-netdb-exchangecache_peer w3-gate2.nctu.edu.tw parent 3128 3130 no-query no-netdb-exchangecache_peer w3-gate2.nctu.edu.tw parent 3128 3130 no-query no-netdb-exchange

• 這裏以 proxy.nctu.edu.tw 給骨幹上的其他 Proxy Servers ( 163.28. *) , 設定為例 ( e.g. NCU, NTU, NCKU, …etc.)

cache_peer w3-gate.nctu.edu.tw sibling 3128 3130 no-netdb-exchange cache_peer w3-gate2.nctu.edu.tw sibling 3128 3130 no-netdb-exchange cache_peer w3-gate3.nctu.edu.tw sibling 3128 3130 no-netdb-exchange

Page 61: 交  通  大  學 計  算  機  中  心 陳  昌  盛 E-mail: cschen@cc.nctu.tw

61

使用交通大學所提供的 Proxy Server 時,您可能會遇到的疑問。

• 為什麼會遇到 Access Denied 的錯誤訊息? – 請確定您是 TANet 新竹區使用者 , 包括交通大學 , 清華大學 ,

高速電腦中心 , 中華大學 , 新竹師院以及其他連接於新竹區網中心的單位

– 請確定您的 IP 之 DNS 正查與反查設定正確 – 請設定 Auto Proxy Configuration – 請將 URL 中的 IP 部分改為 FQDN ,( ex:

http://140.113.250.5 -> http://www.nctu.edu.tw ) 由於 IP 容易造成 auto proxy config 誤判,所以請避免使用 IP 形式之 URL

• 為什麼不能存取 NCTUCCCA.edu.tw? – 新竹地區使用者,請就近利用 NCTUCCCA.NCTU.edu.tw

Page 62: 交  通  大  學 計  算  機  中  心 陳  昌  盛 E-mail: cschen@cc.nctu.tw

62

Proxy Server 統計• NCTU Proxy Servers 使用量排名統計

– proxy, proxy2, proxy3

• NCTU Proxy Servers 使用量統計分析– proxy, proxy2, proxy3

Page 63: 交  通  大  學 計  算  機  中  心 陳  昌  盛 E-mail: cschen@cc.nctu.tw

63

Squid Statistics for proxy.nctu.edu.tw:3128-- http://proxy.nctu.edu.tw/logs/19981127.html

1.Summary of Request Method Usage

2.Summary of Protocol Usage

3.Summary of Client Usage

4.Summary of Server Usage

5.Summary of URL Types

6.Summary of URL Top-Level Domains

7.Client Utilization

8.Top 200 HTTP Requests

9.Top 200 ICP Requests

10.Top 200 CONNECT Requests

Page 64: 交  通  大  學 計  算  機  中  心 陳  昌  盛 E-mail: cschen@cc.nctu.tw

64

Top 10 sites by xfers (1998/11/26) - reqs %all %xfers %hit MB %all %hit kB/xf kB/s

www.geocities.com 185571 4.4 0.0 - 0.0 0.0 - - -

adforce.imgis.com 69912 1.7 71.7 0.0 40.3 0.2 0.0 0.8 1.4

members.xoom.com 65662 1.6 0.0 - 0.0 0.0 - - -

www.girlsjapan.com 40367 1.0 12.0 80.5 30.5 0.1 87.3 6.5 123.2

members.tripod.com 34800 0.8 0.0 - 0.0 0.0 - - -

www.beseen.com 31355 0.7 84.5 48.0 36.4 0.2 41.6 1.4 27.0

members.theglobe.com 30748 0.7 47.5 60.6 1054.8 4.6 67.6 73.9 49.8

imageserv.imgis.com 24728 0.6 80.9 88.3 115.4 0.5 87.1 5.9 276.8

www.microsoft.com 22275 0.5 0.0 - 0.0 0.0 - - -

us.yimg.com 20678 0.5 81.8 85.1 40.1 0.2 85.8 2.4 92.9

Page 65: 交  通  大  學 計  算  機  中  心 陳  昌  盛 E-mail: cschen@cc.nctu.tw

65

Top 10 sites by MB (1998/11/26) -- reqs %all %xfers %hit MB %all %hit kB/xf kB/s

members.theglobe.com 30748 0.7 47.5 60.6 1054.8 4.6 67.6 73.9 49.8

216.49.10.245 16961 0.4 35.3 56.1 945.1 4.1 52.5 161.5 79.7

ftp.cdrom.com 447 0.0 26.2 38.5 594.6 2.6 40.5 5204.4 28.0

www.5senses.com 3534 0.1 100.0 0.0 552.8 2.4 0.0 160.2 7.8

spystream.babenet.com 992 0.0 89.4 4.7 356.2 1.5 0.0 411.3 16.6

streamp.babenet.com 292 0.0 92.5 16.3 329.1 1.4 0.0 1248.0 20.2

ftp.symantec.com 456 0.0 27.2 69.4 325.6 1.4 79.1 2688.5 71.7

www.netaddress.com 1635 0.0 69.4 1.0 294.7 1.3 0.0 266.2 11.3

ftp.zdnet.nis.newscorp. 72 0.0 33.3 12.5 244.4 1.1 0.6 10429.4 14.8

stream10k.redhotnetwork 1184 0.0 94.7 3.7 233.2 1.0 0.0 213.0 12.4

Page 66: 交  通  大  學 計  算  機  中  心 陳  昌  盛 E-mail: cschen@cc.nctu.tw

66

Top 10 neighbor report (1998/11/26) -- reqs %all %xfers %hit MB %all %hit kB/xf kB/s

www.5senses.com 3534 0.1 100.0 0.0 552.8 2.4 0.0 160.2 7.8

216.49.10.245 2611 0.1 95.6 0.0 356.5 1.5 0.0 146.3 3.2

spystream.babenet.com 845 0.0 100.0 0.0 356.1 1.5 0.0 431.6 9.5

ftp.cdrom.com 95 0.0 69.5 0.0 343.2 1.5 0.0 5324.0 4.7

streamp.babenet.com 230 0.0 98.3 0.0 329.0 1.4 0.0 1490.5 13.3

ccproxy.nsysu.edu.tw 10005 0.2 96.2 0.0 324.8 1.4 0.0 34.5 15.1

members.theglobe.com 5713 0.1 87.8 0.0 316.8 1.4 0.0 64.7 6.6

www.netaddress.com 1129 0.0 99.5 0.0 294.7 1.3 0.0 268.7 9.6

w3-gate2.ntu.edu.tw 10530 0.2 98.5 0.0 276.3 1.2 0.0 27.3 14.9

stream10k.redhotnetwork 1079 0.0 100.0 0.0 233.2 1.0 0.0 221.3 11.4

Page 67: 交  通  大  學 計  算  機  中  心 陳  昌  盛 E-mail: cschen@cc.nctu.tw

67

Method report (1998/11/26)

-- reqs %all %xfers %hit MB %all %hit kB/xf kB/s

CONNECT 2543 0.1 100.0 0.0 26.7 0.1 0.0 10.8 1.5

GET 1613164 38.3 97.4 54.1 22943.9 99.7 47.5 15.0 54.6

HEAD 352 0.0 31.2 40.0 0.0 0.0 40.6 0.3 3.4

ICP_QUERY 2590276 61.5 0.0 - 0.0 0.0 - - -

POST 6137 0.1 95.5 0.0 33.0 0.1 0.0 5.8 3.2

Page 68: 交  通  大  學 計  算  機  中  心 陳  昌  盛 E-mail: cschen@cc.nctu.tw

68

Hierarchie code (1998/11/26) -- reqs %all %xfers %hit MB %all %hit kB/xf kB/s

DIRECT 526243 12.5 98.2 0.0 6656.3 28.9 0.0 13.2 4.5

NONE 3460966 82.2 24.6 100.0 10889.6 47.3 100.0 13.1 96.5

SIBLING_HIT 40991 1.0 97.6 0.0 1144.2 5.0 0.0 29.3 18.5

TIMEOUT_DIRECT 184272 4.4 93.2 0.0 4313.6 18.8 0.0 25.7 3.7

Page 69: 交  通  大  學 計  算  機  中  心 陳  昌  盛 E-mail: cschen@cc.nctu.tw

69

Object type report (1998/11/26) -- reqs %all %xfers %hit MB %all %hit kB/xf kB/s

ASCII 13029 0.3 14.5 44.6 19.0 0.1 53.6 10.3 33.5

ASP 23031 0.5 11.1 0.6 15.7 0.1 0.0 6.3 4.2

Archive 23818 0.6 19.3 43.8 3441.8 15.0 46.3 765.2 42.1

Binary 7629 0.2 21.7 53.4 3765.7 16.4 51.7 2327.1 34.4

CGI 108998 2.6 28.5 0.3 34.1 0.1 0.0 1.1 0.9

Document 1912 0.0 23.2 13.5 98.3 0.4 27.2 227.1 28.4

Graphics 2827547 67.1 38.4 69.7 9198.1 40.0 60.8 8.7 68.6

HTML 608457 14.4 29.2 41.3 1132.9 4.9 31.0 6.5 47.4

Java 14420 0.3 30.1 76.9 17.1 0.1 67.9 4.0 60.9

Movie 2778 0.1 29.2 43.5 1304.4 5.7 43.9 1647.0 57.4

RealAudio 2074 0.0 11.5 32.4 43.3 0.2 26.5 186.3 14.6

Sound 11934 0.3 16.9 60.8 682.0 3.0 34.9 345.4 90.1

Unknown 566845 13.5 46.7 3.8 3251.3 14.1 16.7 12.6 7.0

Page 70: 交  通  大  學 計  算  機  中  心 陳  昌  盛 E-mail: cschen@cc.nctu.tw

70

Weekly report (1998/11/26)

Week begin reqs %all %xfers %hit MB %all %hit kB/xf kB/s

1998/11/19 4212472 100.0 37.5 53.9 23003.7 100.0 47.3 14.9 54.3

Total report reqs %all %xfers %hit MB %all %hit kB/xf kB/s

All requests 4212472 100.0 37.5 53.9 23003.7 100.0 47.3 14.9 54.3

Page 71: 交  通  大  學 計  算  機  中  心 陳  昌  盛 E-mail: cschen@cc.nctu.tw

71

Cache Manager menu for localhost:• Callback Data Registry Contents • Memory Utilization • Current Squid Configuration (hidden). • comm_incoming() stats • IP Cache Stats and Contents • FQDN Cache Stats and Contents • Dnsserver Statistics • HTTP Header Statistics • This Cachemanager Menu • Shut Down the Squid Process (hidden). • General Runtime Information • Process Filedescriptor Allocation • All Cache Objects • In-Memory and In-Transit Objects • Objects with Swapout files open • Server-side network read() size histograms • Traffic and Resource Counters • Peer Selection Algorithms

Page 72: 交  通  大  學 計  算  機  中  心 陳  昌  盛 E-mail: cschen@cc.nctu.tw

72

Cache Manager menu for localhost: (cont.) • Cache Digest and ICP blob • 5 Minute Average of Counters • 60 Minute Average of Counters • Cache Utilization • Full Histogram Counts • Client-side Active Requests • Store Directory Stats • storeCheckCachable() Stats • Persistent Connection Utilization Histograms • Event Queue • Refresh Algorithm Statistics • Request Forwarding Statistics • Cache Client List • AS Number Database • Peer Cache Statistics • List of Unknown sites sending ICP messages

Generated Thu, 06 May 1999 13:43:52 GMT, by cachemgr.cgi/[email protected]

Page 73: 交  通  大  學 計  算  機  中  心 陳  昌  盛 E-mail: cschen@cc.nctu.tw

73

End, Thank you !