Linux5.5下安裝squid2.7反向代理

./configure \
--prefix=/usr/local/squid \
--disable-internal-dns \
--enable-forward-log   \
--enable-follow-x-forwarded-for \
--enable-snmp \
--enable-linux-netfilter  \
--enable-http-violations \
--enable-delay-pools \
--enable-storeio=diskd,aufs,ufs,coss \
--with-coss-membuf-size=8388608 \
--with-large-files \
--enable-large-cache-files \
--with-maxfd=8192 \
--enable-removal-policies=lru,heap \
--enable-useragent-log \
--enable-referer-log  \
--enable-err-languages=Simplify_Chinese \
--enable-default-err-language=Simplify_Chinese
make && make install
 
mkdir /usr/local/squid/var/cache
chown -R nobody.nobody /usr/local/squid/var/cache
chown -R nobody.nobody /usr/local/squid/var/logs
 
vim /usr/local/squid/etc/squid.conf
visible_hostname zj.163.com
http_port 10.80.11.212:80 vhost vport
icp_port 0
cache_mem 1024 MB
cache_swap_low 90
cache_swap_high 95
maximum_object_size 20000 KB
maximum_object_size_in_memory 4096 KB
cache_dir ufs /usr/local/squid/var/cache 10000 16 256
ipcache_size 10240
fqdncache_size 10240
cache_store_log none
emulate_httpd_log on
logformat combined %>a %ui %un [%tl] "%rm %ru HTTP/%rv" %Hs %<st "%{Referer}>h" "%{User-Agent}>h" %Ss:%Sh
pid_filename /usr/local/squid/squid.pid
cache_log /usr/local/squid/var/cache/cache.log
access_log /usr/local/squid/var/logs/access.log combined
cache_mgr yhl@zjhcsoft.com
memory_pools off
memory_pools_limit none
#local mamage
acl manager proto cache_object
acl localhost src 127.0.0.1 10.80.11.212
http_access allow manager localhost
http_access deny manager
acl all src 0.0.0.0/0.0.0.0
http_access allow all
#deny this file cache
acl QUERY urlpath_regex cgi-bin .jsp .do .php .cgi .avi .wmv .rm .ram .mpg .mpeg .zip .exe
cache deny QUERY
#acl picurl url_regex -i \.bmp$ \.png$ \.jpg$ \.gif$ \.jpeg$
#acl mystie1 referer_regex -i ct10000
#http_access allow mystie1 picurl
#acl nullref referer_regex -i ^$
#http_access allow nullref
#acl hasref referer_regex -i .+
#http_access deny hasref picurl
cache_peer 10.80.11.208 parent 80 0 no-query originserver name=web1
cache_peer_domain web1 zj.163.com
cache_effective_user nobody
cache_effective_group nobody
 
 
初始化你在 squid.conf 裏配置的 cache 目錄
/usr/local/squid/sbin/squid -zX
驗證 squid.conf 的 語法和配置
/usr/local/squid/sbin/squid -k parse
前臺啓動squid,並輸出啓動過程
/usr/local/squid/sbin/squid -N -d1
出現2010/06/21 15:36:44| Ready to serve requests. 說明啓動成功
而後 ctrl + c,中止squid,並之後臺運行的方式啓動它
啓動squid在後臺運行
/usr/local/squid/sbin/squid -s
中止 squid
/usr/local/squid/sbin/squid -k shutdown
要執行兩次才能正常關閉squid
重引導修改過的 squid.conf
/usr/local/squid/sbin/squid -k reconfigure
可能經過squidclient這個工具來查看squid的運行狀況,緩存命中率等
/usr/local/squid/bin/squidclient -h 10.80.11.203 -p 80 mgr:info
可查看各選項的使用說明
/usr/local/squid/bin/squidclient -h 10.80.11.203 -p 80 mgr:
內存使用狀況可經過以下選項查看
/usr/local/squid/bin/squidclient -h 10.80.11.203 -p 80 mgr:mem
查看你的日誌文檔
more /usr/local/squid/var/logs/access.log | grep TCP_MEM_HIT
該指令能夠看到在squid運行過程當中,有那些文件被squid緩存到內存中,並返回給訪問用戶
more /usr/local/squid/var/logs/access.log | grep TCP_HIT
該指令能夠看到在squid運行過程當中,有那些文件被squid緩存到cache目錄中,並返回給訪問用戶
more /usr/local/squid/var/logs/access.log | grep TCP_MISS
該指令能夠看到在squid運行過程當中,有那些文件沒有被squid緩存,而是現重原始服務器獲取並返回給訪問用戶
 
相關文章
相關標籤/搜索