FreeBSD/squid のバックアップ(No.1)
- バックアップ一覧
- 差分 を表示
- 現在との差分 を表示
- 現在との差分 - Visual を表示
- ソース を表示
- FreeBSD/squid へ行く。
- 1 (2007-03-16 (金) 03:03:04)
- 2 (2007-03-18 (日) 23:31:57)
- 3 (2007-03-27 (火) 01:11:38)
squid【スクイッド】 †
スクイッドと読むらしいですね。日本語訳するとヤリイカの事だそうです。
squidでプロキシキャッシュサーバを作成してみたいと思います。
環境 †
FreeBSD 6.0
squid 2.5
インストール †
# cd /usr/ports/www/squid # make install clean ;rehash
/usr/local/etc/squid/squid.confを設定 †
こんな感じで設定、ほとんどはデフォルトのままです。
no_cache deny QUERY cache_dir ufs /usr/local/squid/cache 100 16 256 ↑cacheフォルダの場所指定/キャッシュ容量/サブフォルダ数/更にサブフォルダ数 cache_log /usr/local/squid/logs/cache.log cache_store_log /usr/local/squid/logs/store.log pid_filename /usr/local/squid/logs/squid.pid auth_param basic children 5 auth_param basic realm Squid proxy-caching web server auth_param basic credentialsttl 2 hours auth_param basic casesensitive off refresh_pattern ^ftp: 1440 20% 10080 refresh_pattern ^gopher: 1440 0% 1440 refresh_pattern . 0 20% 4320 acl all src 0.0.0.0/0.0.0.0 acl manager proto cache_object acl localhost src 127.0.0.1/255.255.255.255 acl to_localhost dst 127.0.0.0/8 acl SSL_ports port 443 563 acl Safe_ports port 80 # http acl Safe_ports port 21 # ftp acl Safe_ports port 443 563 # https, snews acl Safe_ports port 70 # gopher acl Safe_ports port 210 # wais acl Safe_ports port 1025-65535 # unregistered ports acl Safe_ports port 280 # http-mgmt acl Safe_ports port 488 # gss-http acl Safe_ports port 591 # filemaker acl Safe_ports port 777 # multiling http acl CONNECT method CONNECT acl private src 192.168.1.0/255.255.255.0 http_access allow manager localhost http_access allow private http_access deny manager http_access deny !Safe_ports http_access deny CONNECT !SSL_ports http_access deny all http_reply_access allow all icp_access allow all header_access Cache-Control deny all header_access Via deny all header_access X-Forwarded-For deny all header_access Server deny all header_access User-Agent deny all header_access Accept allow all header_replace User-Agent Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0) coredump_dir /usr/local/squid/cache
起動 †
■squid.conf修正後、下記のコマンドでキャッシュディレクトリを作成する。
# squid -z
■起動シェルにて起動。
# /usr/local/etc/rc.d/squid start
確認 †
後はブラウザにProxy設定をして確認します。⇒Windows/Proxy
これ⇒診断君でチェックしてみました。
キャッシュクリア †
■下記の手順でキャッシュクリアできます。起動シェルなどに組み込んだ方がいいかもしれません。
# /usr/local/etc/rc.d/squid stop # rm -rf /usr/local/squid/cache/* # squid -z # /usr/local/etc/rc.d/squid start
ログローテート †
■squidのログローテートは下記のコマンドで行います。
# /usr/local/sbin/squid -k rotate
キャッシュさせたくない場合 †
■/usr/local/etc/squid/squid.confでno_cashで指定する。
# vi /usr/local/etc/squid/squid.conf ------------------例--------------------- acl QUERY1 urlpath_regex cgi-bin \? no_cache deny QUERY1 ↑cgi-bin ?を含むURLをキャッシュしない acl SERVER1 dstdomain www.flateight.com no_cache deny SERVER1 ↑www.flateight.comのドメインをキャッシュしない no_cac acl QUERY2 url_regex yahoo\.co\.jp no_cache deny QUERY2 ↑yahoo.co.jpを含むURLをキャッシュしない -------------------例--------------------
設定後は一回サービスをリスタートします。