iT邦幫忙

0

Linux squid 直接連線 .

請問各位高手 看書 查到 直接連線的語法 為
acl direct-net dstdomain .acore.com.tw

always_direct allow direct-net

那如果acore.com.tw要外加 2222 port

有加port 的直接連線語法嗎?

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

2 個回答

10
逮丸逮丸
iT邦大師 1 級 ‧ 2010-10-09 07:06:22
最佳解答

proxy server 不見得只有單一台 proxy,
例如像這張圖示:

圖來自http://www.linuxjournal.com/article/2628
圖中的A,B,C是sibling(中文類似是兄弟或鄰居或平輩的意思)的關係,
D對A,B,C而言是parent(父輩、上一層)的關係。
圖中的ISP Proxy-cache 對D而言,也是parent的關係。

如果所用的 proxy 上有設 sibling, parent 的項目的話,
應會像這張圖的請求網頁的流程:

圖來自http://www.sups.tp.edu.tw/infocenter/course/unix/proxy2.html

透過上述兩圖的簡單意思是:
向proxyA請求一網頁時,
1.proxyA會先向 左右平輩的 proxyB,C看是否曾抓過,
2.proxyB,C收到A的請求,檢查其是否曾有同樣的cache,來回應A
2.1如果回應是有的話,就從 左右平輩的proxyB,C的 cache 拿過來給使用端。
2.2如果回應沒有的話,proxyA就向上一層的proxyD來請求,
3.而上一層proxyD收到請求後,檢查其是否曾有同樣的cache,來回應A
3.1如果回應是有的話,就把D裡的cache送給A
3.2如果回應沒有的話,就依D裡的設定,可能是直接去抓原網站的資料,
或者若有定義上一層的proxy,向那D的父輩層請求。

再看一下有關 always_direct 的說明:
http://www.squid-cache.org/Doc/config/always_direct/

ALWAYS be forwarded by Squid to the origin servers without using any peers.

文中的peers 就是指該proxy的父輩層或平輩層。
也就是在proxyA定這規則時:
acl direct-net dstdomain .acore.com.tw
always_direct allow direct-net
proxyA看到是要連*.acore.com.tw 的網頁時,
不會向 proxyB,C,D 去詢問有沒有cache可直接拿,
而直接向 acore.com.tw 的原網站抓取。
另外這always_direct與是否拿proxy中的cache沒有關係:

NOTE: This directive is not related to caching. The replies
is cached as usual even if you use always_direct. To not cache
the replies see the 'cache' directive.

所以這always_direct是指與proxy的平輩、父輩的proxy之間的關係而言,
不是指 要不要 不存原網頁成cache 或 不拿proxy中該網頁的 cache。

若是 不想把所指定的網站 存成cache,
而都是去原網站抓網頁回來,
要用 cache 的語法:

<pre class="c" name="code">#  TAG: cache
A list of ACL elements which, if matched, cause the request to
not be satisfied from the cache and the reply to not be cached.
In other words, use this to force certain objects to never be cached.

You must use the word 'DENY' to indicate the ACL names which should
NOT be cached.

Default is to allow all to be cached.

Default:
none

使用方式可參考:
how do I configure Squid not to cache a specific server?

<pre class="c" name="code">acl someserver dstdomain .someserver.com
cache deny someserver
6
ansonchen
iT邦新手 1 級 ‧ 2010-10-09 00:26:55

Squid 應用很彈性
幾個好用的語法方式

  1. 可透過ACL直接訂route policy
  2. 再選擇要走的proxy mode (有3種方式)
  3. 定義ACL policy走哪各proxy (若沒定走的proxy則會以第一筆Parent proxy依序)

如您的acl

always_direct allow direct-net

則是透過本機proxy連線,並非直接連線喔!!

Squid真的好用, 還可以搭配L7 filter

我要發表回答

立即登入回答