反向代理伺服器 squid 保護 apache

前言:
由於我的架構是 Linux NAT + FreeBSD Web
因此不必更改任何一個 Service 的 port number.


1. squid 設定:

我的安排是 squid on CentOS + apache on FreeBSD
以下是 squid on CentOS 的設定 (#中位置是 FreeBSD 的)

CODE:

 ########## Base control ##########
 cache_mgr webmaster
 cache_effective_user squid
 cache_effective_group squid
 visible_hostname cache.arule.net
 http_port 80
 icp_port 0
 
 #cache_dir ufs /usr/cache 300 16 256
 cache_dir ufs /var/spool/squid 300 16 256
 #cache_access_log /var/log/squid-cache-access.log
 #cache_log /var/log/cache.log
 #cache_store_log /var/log/cache_store.log
 #error_directory /s/squid/etc/squid/errors/Simplify_Chinese
 error_directory /usr/share/squid/errors/English
 #icon_directory /s/squid/etc/squid/icons
 icon_directory /usr/share/squid/icons
 #mime_table /s/squid/etc/squid/mime.conf
 mime_table /etc/squid/mime.conf
 #coredump_dir /s/squid/squid/cache
 coredump_dir /var/spool/squid
 #pid_filename /s/squid/squid/logs/squid.pid
 pid_filename /var/run/squid.pid
 hosts_file /data/squidhosts
 #unlinkd_program /s/squid/libexec/squid/unlinkd
 unlinkd_program /usr/lib/squid/unlinkd
 
 ########## Performance control ##########
 
 cache_mem 256 MB
 cache_swap_low 90
 cache_swap_high 95
 maximum_object_size 4096 KB
 minimum_object_size 0 KB
 maximum_object_size_in_memory 8 KB
 ipcache_size 1024
 ipcache_low 90
 ipcache_high 95
 fqdncache_size 1024
 cache_replacement_policy lru
 memory_replacement_policy lru
 emulate_httpd_log on
 log_ip_on_direct on
 log_mime_hdrs off
 dns_timeout 2 minutes
 request_header_max_size 10 KB
 
 


其中 /etc/squidhosts 中這麼設定
192.168.2.20 www.arule.net
這樣的話 squid 就會合法的快取它了,
我新增一個 virtualhost 後就用同樣的方法寫入 squidhosts
然後重新啟動 squid 就可直接利用 squid 瀏覽了

2.apache 設定


因為都有 squid 保護了,所以我就加減弄個 mod_mem

CODE:

 
 CacheForceCompletion 100
 CacheDefaultExpire 3600
 CacheMaxExpire 86400
 CacheLastModifiedFactor 0.1
 
 CacheEnable disk /
 CacheRoot /data/
 CacheSize 327680
 CacheDirLength 4
 CacheDirLevels 5
 CacheGcInterval 4
 
 
 CacheEnable mem /
 MCacheSize 8192
 MCacheMaxObjectCount 10000
 MCacheMinObjectSize 1
 MCacheMaxObjectSize 51200
 
 
 


後記:
設定好之後,有兩個缺點:

1. apache的access log 全部都 log 到 Linux 的區域網路 ip.
這個目前不知道怎麼解...

2. squid 的模擬 apache log 不完整
這個缺點看網頁上是說可以用 patch 的方式讓 squid 支援 apache combined log.

兩個都麻煩,因此暫時按兵不動....
引用通告地址: 點擊獲取引用地址
標籤: 應用服務 Application Service 網路 Network
評論: 0 | 引用: 0 | 閱讀: 800 | 轉發
發表評論
暱 稱: 密 碼:
網 址: E - mail:
選 項:    
頭 像:
內 容:
  • 粗體
  • 斜體
  • 底線
  • 插入圖片
  • 超連結
  • 電子郵件
  • 插入引用