反向代理伺服器 squid 保護 apache
作者: 不小心被逼到會 日期: 2007-11-07 01:40
前言:
由於我的架構是 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.
兩個都麻煩,因此暫時按兵不動....
發表評論
訂閱
上一篇
返回
下一篇
標籤:
把 tomcat 管理畫面洗掉 (2008-01-30 09:46)
使用 telnet 連上 IRC Server (2007-11-22 01:02)
AWStats 產生靜態頁面 (2007-11-19 19:45)
distccd on CentOS (2007-10-08 19:55)
讓 apache 支援 PUT Method (2007-10-05 12:12)
SVN+Apache 搭配Ldap認證設定 (2007-10-03 17:47)
CentOS Syslog Server (2007-08-23 21:11)