日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 人文社科 > 生活经验 >内容正文

生活经验

对Squid使用的一些总结

發(fā)布時間:2023/11/27 生活经验 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 对Squid使用的一些总结 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
對Squid使用的幾點(diǎn)總結(jié)

1.cache_dir

在Linux環(huán)境下用aufs類型的cache_dir比較穩(wěn)定,速度也比較快。cache_dir所在文件系統(tǒng)如果用noatime選項(xiàng)來mount,可以避

免訪問cache文件時經(jīng)常要更新access time的操作。

一般cache容量和被加速內(nèi)容的比值在1:10到1:20比較合適。

cache_dir aufs /var/spool/squid 10240 64 64
這是一個典型網(wǎng)站web caching server的cache_dir配置,加速100GB到200GB的內(nèi)容

cache_dir aufs /var/spool/squid 1024 16 64
這是一個典型辦公室透明代理的cache_dir配置,加速10GB到20GB的內(nèi)容


2.cache_mem

很多文章說cache_mem要設(shè)置成物理內(nèi)存數(shù)量的一半,比如物理內(nèi)存2GB的cache_mem要設(shè)置成1GB。但是經(jīng)過實(shí)際使用檢驗(yàn),這往往

是造成服務(wù)器內(nèi)存超負(fù)荷的元兇。《Squid: The Definitive Guide》關(guān)于cache_mem這樣說:“This directive doesn‘t?

entirely control the size of the Squid process”。實(shí)際使用當(dāng)中內(nèi)存占用往往超過cache_mem限定值很多,也就是說,

squid占用內(nèi)存量似乎不受這個參數(shù)的控制。所以,此參數(shù)不必設(shè)得太大,適量就行,我的設(shè)置是:

服務(wù)器:
cache_mem 100 MB

局域網(wǎng):
cache_mem 10 MB

另外,設(shè)置較小的maximum_object_size_in_memory值有助于有效控制squid過度占用內(nèi)存,例如:
maximum_object_size 12288 KB
maximum_object_size_in_memory 24 KB

memory_pools off,也是一個不錯的設(shè)置

題外話,個人覺得squid這個軟件設(shè)計(jì)的比較失敗的地方就是內(nèi)存管理這一塊...


3.透明代理

防火墻設(shè)置好端口攔截,然后這樣設(shè)置可以實(shí)現(xiàn)透明代理:

httpd_accel_port 80 (0: 加速任何端口)
httpd_accel_host virtual
httpd_accel_uses_host_header on
httpd_accel_with_proxy on


這是使兩種工作模式:代理模式和加速模式,同時工作。要想關(guān)閉代理模式,只要把httpd_accel_with_proxy設(shè)成off


4.http_port

http_port可以重復(fù)設(shè)置,使得squid在多個端口偵聽

http_port 80
http_port 3128
http_port localhost:8080


5.訪問控制

acl it_nets src 192.168.0.0/19 (限制訪問ip)
acl over_conn_limit maxconn 20 (限制連接數(shù))
acl illegal_access url_regex -i what_ever_you_want (限制訪問內(nèi)容)

http_access deny over_conn_limit
http_access deny illegal_access
http_access allow it_nets
http_access deny all


6.cache文件的更新周期

refresh_pattern ^/$ 0 66% 240 reload-into-ims
refresh_pattern ^.+/(<^.>*)$ 0 66% 720 reload-into-ims
(首頁,更新得比較頻繁,cache更新周期短一些)

refresh_pattern -i /.(htm|html|txt|js)$ 0 66% 1440 reload-into-ims
(一般頁面,更新得沒那么頻繁,cache更新周期長一些)

refresh_pattern -i /.(bmp|gif|jpg|png|swf)$ 0 66% 10080 reload-into-ims
(圖片、flash,更新得最不頻繁,cache更新周期最長)

refresh_pattern . 0 66% 10080 reload-into-ims
(缺省,長一些)


reload-into-ims

When set, this option makes Squid transform a request with a no-cache directive into a validation?

(If-Modified-Since) request. In other words, Squid adds an If-Modified-Since header to the request?

before forwarding it on. Note that this only works for objects that have a Last-Modified timestamp.?

The outbound request retains the no-cache directive, so that it reaches the origin server.

大概意思是:只在源服務(wù)器上文件變動的情況下才實(shí)際更新cache當(dāng)中的內(nèi)容。

小技巧:Ctrl+F5可以強(qiáng)制瀏覽器和squid刷新它的緩存。

題外話:內(nèi)容管理系統(tǒng)(CMS)在更新發(fā)布頁面的時候,應(yīng)該與cache服務(wù)器之間有一種溝通機(jī)制,通知cache刷新更新了的內(nèi)容


7.雜項(xiàng)

negative_ttl 0 minutes

pipeline_prefetch on (對提升squid處理客戶端請求的速度有幫助)

forwarded_for on

dns_nameservers 202.96.128.86 202.96.128.166


8.Squid+Apache

在apache服務(wù)器中前置squid,可以有效減少apache衍生進(jìn)程的數(shù)量,從而減少內(nèi)存消耗。

利用Squid的訪問控制功能,可以實(shí)現(xiàn)內(nèi)容過濾、連接數(shù)限制等apache力所不能及的功能。

利用Squid的I/O驅(qū)動的請求處理模式,更高效地實(shí)現(xiàn)靜態(tài)內(nèi)容請求處理,至于動態(tài)內(nèi)容還是交給apache來處理。

9.max_filedesc 16384

這個不用多說了...

10.待續(xù)..

總結(jié)

以上是生活随笔為你收集整理的对Squid使用的一些总结的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。