²©¿Íͳ¼ÆÐÅÏ¢

Óû§Ãû£ºsookk
ÎÄÕÂÊý£º169
ÆÀÂÛÊý£º78
·ÃÎÊÁ¿£º250180
ÎÞÓDZңº588
²©¿Í»ý·Ö£º1084
²©¿ÍµÈ¼¶£º5
×¢²áÈÕÆÚ£º2008-08-20

Ó¦ÓÃsquidÈ«Ãæ¼ÓËÙweb£¨È«£©
2009-11-25 10:40:32
°æÈ¨ÉùÃ÷£ºÔ­´´×÷Æ·£¬Ð»¾ø×ªÔØ£¡·ñÔò½«×·¾¿·¨ÂÉÔðÈΡ£
###############################################
ģʽ1£ºSquid¶ÔÓ¦¶ą̀web·þÎñÆ÷
ÔÚvi /etc/hostsÖУº¼ÓÈëÄÚ²¿µÄDNS½âÎö£¬±ÈÈ磺
192.168.0.9   
www.winkee.com
192.168.0.66    bbs.winkee.com
A2¡¢#vi /Data/apps/squid/etc/squid.conf
´úÂëÈçÏ£º
# visible name
visible_hostname cache.winkee.com
# cache config: space use 1G and memory use 256M
cache_dir ufs /Data/apps/squid/cache 1024 16 256
cache_mem 256 MB
cache_effective_user squid  #ÉèÖÃÔËÐÐʱµÄÓû§ºÍ×éȨÏÞ
cache_effective_group squid
# ·´Ïò¼ÓËÙÅäÖÃ
http_port 80   # squid¼àÌýµÄ¶Ë¿Ú,¿Í»§·ÃÎÊÍøÕ¾µÄ¶Ë¿Ú
httpd_accel_host virtual  # WEB·þÎñÆ÷µÄIPµØÖ·,´ËģʽÏÂÉèÖÃΪ:virtual
httpd_accel_single_host off  # ÉèÖÃonʱ»º³åÇëÇóµ½µ¥Ì¨Server£¬off¶ÔÓ¦virtual
httpd_accel_port 80  # WEB·þÎñÆ÷µÄ¶Ë¿Ú(¶ÔÓÚ¶ą̀web·þÎñÆ÷,¶Ë¿Ú±ØÐëÒ»ÖÂ)
httpd_accel_uses_host_header on  # Íê³É¶à¸öWEB·þÎñÆ÷µÄ·´Ïò´úÀí¹¦ÄÜ
httpd_accel_with_proxy off    # Í£ÓôúÀí±¾µØÉÏÍø
# accelerater my domain only
acl HostA dstdomain 
www.winkee.com
acl HostB dstdomain  bbs.winkee.com
# accelerater http protocol on port 80
acl acceleratedProtocol protocol HTTP
acl acceleratedPort port 80
# access arc
acl all src 0.0.0.0/0.0.0.0
# Allow requests when they are to the accelerated machine AND to the right port with right protocol
http_access allow acceleratedProtocol acceleratedPort HostA
http_access allow acceleratedProtocol acceleratedPort HostB
http_access allow all
# logging
emulate_httpd_log on
cache_store_log none
# manager
acl manager proto cache_object
http_access allow manager all
cachemgr_passwd pass all
cache_mgr
admin@winkee.com
#swap ÐÔÄÜ΢µ÷
half_closed_clients off
cache_swap_high 100%
cache_swap_low 95%
maximum_object_size 1024 KB
# ¿ØÖƶÔÏóµÄ³¬Ê±Ê±¼ä (S_Data-Data)<Min+(Max-Min)*90%
refresh_pattern -i .html 60 90% 10080 reload-into-ims
#refresh_pattern -i \.html$ 60 90% 10080 reload-into-ims
refresh_pattern -i .png 60 90% 10080 reload-into-ims
refresh_pattern -i .jpg 1440 90% 129600 reload-into-ims
refresh_pattern -i .gif 1440 90% 129600 reload-into-ims
refresh_pattern -i .js 1440 90% 10080 reload-into-ims
refresh_pattern -i .swf 1440 90% 129600 reload-into-ims
refresh_pattern -i .bmp 1440 90% 129600 reload-into-ims
# refresh_pattern -i .shtml 1440 90% 129600 reload-into-ims
# refresh_pattern -i .hml 1440 90% 129600 reload-into-ims
# ½ûÖ¹»º´æ
hierarchy_stoplist cgi-bin ?
hierarchy_stoplist -i ^https:\\ ?
acl QUERY urlpath_regex -i cgi-bin \? \.php \.xml
acl denyssl urlpath_regex -i ^https:\\
no_cache deny QUERY
no_cache deny denyssl
#logfile_rotate ¿ÉÒÔÓÃlogfile_rotate 0À´È¡Ïû×Ô¶¯²Ù×÷
logfile_rotate 4[/quote]
########################################################
ģʽ£²£ºSquid Óë webÊǵ¥¶ÀÁ½Ì¨·þÎñÆ÷
# vi /Data/apps/squid/etc/squid.conf  ´úÂëÈçÏ£º
# visible name
visible_hostname cache.winkee.com
# cache config: space use 1G and memory use 256M
cache_dir ufs /Data/apps/squid/cache 1024 16 256
cache_mem 256 MB
cache_effective_user squid  #ÉèÖÃÔËÐÐʱµÄÓû§ºÍ×éȨÏÞ
cache_effective_group squid
# ·´Ïò¼ÓËÙÅäÖÃ
http_port 80   # squid¼àÌýµÄ¶Ë¿Ú,¿Í»§·ÃÎÊÍøÕ¾µÄ¶Ë¿Ú
httpd_accel_host ip_address  # WEB·þÎñÆ÷µÄIPµØÖ·
httpd_accel_single_host on # ÉèÖÃת·¢Îª»º³åµÄÇëÇóµ½Ò»Ì¨µ¥¶ÀµÄ»úÆ÷
httpd_accel_port 80    # WEB·þÎñÆ÷µÄ¶Ë¿Ú
httpd_accel_uses_host_header off  # Íê³Éµ¥Ì¨WEB·þÎñÆ÷µÄ·´Ïò´úÀí¹¦ÄÜ
httpd_accel_with_proxy off    # Í£ÓôúÀí±¾µØÉÏÍø
# accelerater my domain only
acl HostA dst ip_address # WEB·þÎñÆ÷µÄIPµØÖ·
# accelerater http protocol on port 80
acl acceleratedProtocol protocol HTTP
acl acceleratedPort port 80
# access arc
acl all src 0.0.0.0/0.0.0.0
# Allow requests when they are to the accelerated machine AND to the right port with right protocol
http_access allow acceleratedProtocol acceleratedPort HostA
http_access allow all
# logging
emulate_httpd_log on
cache_store_log none
# manager
acl manager proto cache_object
http_access allow manager all
cachemgr_passwd pass all
cache_mgr
admin@winkee.com
#swap ÐÔÄÜ΢µ÷
half_closed_clients off
cache_swap_high 100%
cache_swap_low 95%
maximum_object_size 1024 KB
# ¿ØÖƶÔÏóµÄ³¬Ê±Ê±¼ä (S_Data-Data)<Min+(Max-Min)*90%
refresh_pattern -i .html 60 90% 10080 reload-into-ims
refresh_pattern -i .png 60 90% 10080 reload-into-ims
refresh_pattern -i .jpg 1440 90% 129600 reload-into-ims
refresh_pattern -i .gif 1440 90% 129600 reload-into-ims
refresh_pattern -i .js 1440 90% 10080 reload-into-ims
refresh_pattern -i .swf 1440 90% 129600 reload-into-ims
refresh_pattern -i .bmp 1440 90% 129600 reload-into-ims
# refresh_pattern -i .shtml 1440 90% 129600 reload-into-ims
# refresh_pattern -i .hml 1440 90% 129600 reload-into-ims
# ½ûÖ¹»º´æ
hierarchy_stoplist cgi-bin ?
hierarchy_stoplist -i ^https:\\ ?
acl QUERY urlpath_regex -i cgi-bin \? \.php \.xml
acl denyssl urlpath_regex -i ^https:\\
no_cache deny QUERY
no_cache deny denyssl
#logfile_rotate ¿ÉÒÔÓÃlogfile_rotate 0À´È¡Ïû×Ô¶¯²Ù×÷
logfile_rotate 4
###########################################################
ģʽ£³£ºSquid Óë WebÊÇͬһ̨·þÎñÆ÷
# vi /Data/apps/squid/etc/squid.conf  ´úÂëÈçÏ£º
# visible name
visible_hostname cache.winkee.com
# cache config: space use 1G and memory use 256M
cache_dir ufs /Data/apps/squid/cache 1024 16 256
cache_mem 256 MB
cache_effective_user squid  #ÉèÖÃÔËÐÐʱµÄÓû§ºÍ×éȨÏÞ
cache_effective_group squid
# ·´Ïò¼ÓËÙÅäÖÃ
http_port 80   # squid¼àÌýµÄ¶Ë¿Ú,¿Í»§·ÃÎÊÍøÕ¾µÄ¶Ë¿Ú
httpd_accel_host ip_address  # WEB·þÎñÆ÷µÄIPµØÖ·
httpd_accel_single_host on # ÉèÖÃת·¢Îª»º³åµÄÇëÇóµ½Ò»Ì¨µ¥¶ÀµÄ»úÆ÷
httpd_accel_port 81    # WEB·þÎñÆ÷µÄ¶Ë¿Ú
httpd_accel_uses_host_header off  # Íê³Éµ¥Ì¨WEB·þÎñÆ÷µÄ·´Ïò´úÀí¹¦ÄÜ
httpd_accel_with_proxy off    # Í£ÓôúÀí±¾µØÉÏÍø
# accelerater my domain only
acl HostA dst ip_address # WEB·þÎñÆ÷µÄIPµØÖ·
# accelerater http protocol on port 80
acl acceleratedProtocol protocol HTTP
acl acceleratedPort port 80
# access arc
acl all src 0.0.0.0/0.0.0.0
# Allow requests when they are to the accelerated machine AND to the right port with right protocol
http_access allow acceleratedProtocol acceleratedPort HostA
http_access allow all
# logging
emulate_httpd_log on
cache_store_log none
# manager
acl manager proto cache_object
http_access allow manager all
cachemgr_passwd pass all
cache_mgr
admin@winkee.com
#swap ÐÔÄÜ΢µ÷
half_closed_clients off
cache_swap_high 100%
cache_swap_low 95%
maximum_object_size 1024 KB
# ¿ØÖƶÔÏóµÄ³¬Ê±Ê±¼ä (S_Data-Data)<Min+(Max-Min)*90%
refresh_pattern -i .html 60 90% 10080 reload-into-ims
refresh_pattern -i .png 60 90% 10080 reload-into-ims
refresh_pattern -i .jpg 1440 90% 129600 reload-into-ims
refresh_pattern -i .gif 1440 90% 129600 reload-into-ims
refresh_pattern -i .js 1440 90% 10080 reload-into-ims
refresh_pattern -i .swf 1440 90% 129600 reload-into-ims
refresh_pattern -i .bmp 1440 90% 129600 reload-into-ims
# refresh_pattern -i .shtml 1440 90% 129600 reload-into-ims
# refresh_pattern -i .hml 1440 90% 129600 reload-into-ims
# ½ûÖ¹»º´æ
hierarchy_stoplist cgi-bin ?
hierarchy_stoplist -i ^https:\\ ?
acl QUERY urlpath_regex -i cgi-bin \? \.php \.xml
acl denyssl urlpath_regex -i ^https:\\
no_cache deny QUERY
no_cache deny denyssl
# logfile_rotate ¿ÉÒÔÓÃlogfile_rotate 0À´È¡Ïû×Ô¶¯²Ù×÷
logfile_rotate 4
 
Setp £³ ¨CStarting Squid
£±¡¢    ´´½¨»º´æÄ¿Â¼
# cd /Data/apps/squid/sbin
#./squid ¨Cz   # ³öÏÖCreating Swap DirectoriesÌáʾ£¬±íʾ½¨Á¢³É¹¦
£²¡¢    ÔËÐÐSquid
# cd /Data/apps/squid/sbin
#./squid ¨CNCd1 # ³É¹¦ºó½«³öÏÖ"Ready to serve requests".·ñÔòÇë¼ì²éÅäÖÃÎļþ
˵Ã÷£¬ÓÃsquid -NCd1À´ÒÔdebugģʽÆô¶¯£¬ÕâÑùÈç¹ûÓдíÎó»á±¨³öÀ´£¬Ò»°ãÈç¹ûÊÇADSL²¦ºÅµÄ£¬ÄÇôÔÚûÓв¦ºÅ֮ǰ¾ÍÆô¶¯squidµÄ»°ÊÇ»á³ö´íµÄ(FATAL: ipcache_init: DNS name lookup tests failed)£¬ÒòΪsquidÆô¶¯Ê±»áÈ¥¼ì²éһЩ³£ÓõÄDNS£¬µ«ÊÇÕâʱºòÄ㲢ûÓнÓÈëinternet£¬×ÔÈ»¾Í³ö´íÁË£¬ËùÒÔÎÒÃÇÐèÒªÔÚÆô¶¯µÄʱºò²»¼ì²éDNS£¬Õâ¾ÍÐèÒªÓüÓÉÏ-DÑ¡ÏîÀ´Æô¶¯squid£¬ÃüÁîÈçÏ£º
#./squid ¨CNCDd1 # ²ÎÊýDd1µÄÄ¿µÄÊǽûÖ¹²âÊÔDNSµÄÁ¬Í¨ÐÔ²¢ÇÒ°ÑsquidÔÚ¿ªÊ¼ÔËÐкóµÄһЩÌáʾÐÅÏ¢ÏÔʾÔÚÆÁÄ»ÉÏ)
×¢ÒâÊÂÏ
1¡¢SquidµÄÅäÖÃÎļþsquid.conf¸ü¸Äºó±ØÐëÖØÐÂÔËÐÐsquid
2¡¢Squid·þÎñÆ÷µÄhostsÎļþ¸ü¸Äºó±ØÐëÖØÐÂÔËÐÐsquid

±¾Îijö×Ô ¡°linux½ø½×ÎÝ¡± ²©¿Í£¬Ð»¾ø×ªÔØ£¡

·ÖÏíÖÁ
¸ü¶à
Ò»¼üÊղأ¬ËæÊ±²é¿´£¬·ÖÏíºÃÓÑ£¡
0ÈË
ÁËÕâÆªÎÄÕÂ
Àà±ð£ºLinux©ª¼¼ÊõȦ()©ªÔĶÁ()©ªÆÀÂÛ() ©ª ÍÆË͵½¼¼ÊõȦ©ª·µ»ØÊ×Ò³

ÎÄÕÂÆÀÂÛ

 
 

·¢±íÆÀÂÛ            

¡¾¼¼ÊõÃÅÕר¼Ò½âÎö£ºÈí¿¼ÖØµãÄѵ㼰ӦÊÔ¼¼ÇÉ
êÇ  ³Æ£º
µÇ¼  ¿ìËÙ×¢²á
ÑéÖ¤Â룺

Çëµã»÷ºóÊäÈëÑéÖ¤Â벩¿Í¹ý2¼¶£¬ÎÞÐèÌîдÑéÖ¤Âë

ÄÚ  ÈÝ£º