最終更新:2009-10-27 (火) 10:50:26 (5288d)
Squidのチョイ規模でかめで参考になりそうなconfとコメント
Top / Squidのチョイ規模でかめで参考になりそうなconfとコメント
#squidの動作させるユーザ・グループ cache_effective_user squid cache_effective_group nogroup #squidはcache_memの約3倍のメモリを使います cache_mem 64 MB #diskdはsquidと別スレッドでディスクに書込みします。複数cpuに最適値。最初の100は使用ディスク容量(MB単位) cache_dir diskd /var/cache/squid 100 16 256 #半接続で落ちたクライアントをすぐに切る half_closed_clients off #再起動/終了時の待ち時間 shutdown_lifetime 3 seconds #メモリに読み込むキャッシュオブジェクトの最大容量 maximum_object_size_in_memory 5 MB #ステータスページのパスワードを無効にする(本番では要変更) cachemgr_passwd none all #エラーステータス(404など)のキャッシュ時間を小さく取る negative_ttl 1 minutes #リクエストのリダイレクト時のホストヘッダの書き換えを禁止 url_rewrite_host_header off #キャッシュが他にないのでアナウンスしない announce_period 0 #icpを禁止 icp_port 0 #メモリをつかんだら解放しないで取っておく memory_pools on #メモリは使えるだけ使う(専用サーバ用設定) memory_pools_limit 0 #最大2本のパラレルでデータの送受信を行う pipeline_prefetch on #最小無効化時間を短めに取る minimum_expiry_time 2 seconds #パーシスタントコネクションの最長値を短めに取る pconn_timeout 30 seconds #全てのデータを2分間キャッシュする。ページのリロードが来てもキャッシュを返す。 refresh_pattern . 2 100% 2 ignore-reload #アクセスログのフォーマット logformat combined %>a %ui %un [%tl] "%rm %ru HTTP/%rv" %Hs %h" "%{User-Agent}>h" %Ss:%Sh #アクセスログの位置と書式 access_log /var/log/squid/access.log combined #apacheと似たようなログを吐く #emulate_httpd_log on #apacheサーバの場合にいいかげんなvary_encodingを許可する acl apache rep_header Server ^Apache broken_vary_encoding allow apache #アクセスコントロールリスト(定義部) acl all src 0.0.0.0/0.0.0.0 acl localhost src 127.0.0.1/255.255.255.255 #クライアントからの接続先。 #http(s)//192.168.100.15/.... もしくはhttp(s)//*.una.com/.... が該当。 #もっと明確にサーバを指定したいときは頭にドットを置かずに www.una.com とかする。 acl reverse dstdomain 192.168.100.15 .una.com http_access allow reverse #ステータスページ表示設定。localhostからのみ許可。 #squidclient -p82 -h 192.168.100.15 -l localhost mgr:config | less のようにして取得。 acl manager proto cache_object http_access allow manager localhost http_access deny manager #############一つ目のサーバを指定############# #IPアドレス 127.0.0.1 #アクセラレートするときは parent #ポート 80 #ICPポート 0 # ICPリクエストしない # disables requesting ICMP RTT database (NetDB) from the neighbor. # NOT to request cache digests from this neighbor. # parentをオリジナルサーバとみなす。アクセラレート設定。 # cache_peerに名前を付ける # authをparentにパス # 最大接続数を制限しておく cache_peer 127.0.0.1 parent 80 0 no-query no-netdb-exchange no-digest originserver name=server_1 login=PASS max-conn=100 #一つ目のサーバ用のsquidの待ち受けポート #IPアドレス 192.168.100.15 #ポート 80 # アクセラレートモード # ネームベースヴァーチャルホスト用のヘッダをparentにパス # セキュリティ上 全てのリバースプロキシ設定に別のurlgroupを振ります。 http_port 192.168.100.15:80 accel vhost urlgroup=1 #squidサーバのポート80をaclで定義 acl p80 myport 80 #squidサーバのポート80からの接続のみ1番目のサーバにリバースプロキシする cache_peer_access server_1 allow p80 cache_peer_access server_1 deny all #############一つ目のサーバここまで############# #############ふたつ目のサーバを指定############# cache_peer 127.0.0.1 parent 800 0 no-query no-netdb-exchange no-digest originserver name=server_2 login=PASS max-conn=100 http_port 192.168.100.15:81 accel vhost urlgroup=2 acl p81 myport 81 cache_peer_access server_2 allow p81 cache_peer_access server_2 deny all #############三つ目のサーバをSSLで指定############# cache_peer 127.0.0.1 parent 8043 0 no-query no-netdb-exchange no-digest originserver name=server_3 login=PASS max-conn=100 #SSLなので https_port。http_port と違うところは cert=/PATH/TO/cert.pem と key=/PATH/TO/key.pem あとcipher https_port 192.168.100.15:443 cert=/usr/local/ssl/certs/cert.pem key=/usr/local/ssl/private/key.pem accel vhost urlgroup=3 cipher=ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:-LOW:-SSLv2:-EXP:-eNULL acl p443 myport 443 cache_peer_access server_3 allow p443 cache_peer_access server_3 deny all #############四つ目のサーバを指定############# cache_peer www.yahoo.com parent 80 0 no-query no-netdb-exchange no-digest originserver name=server_4 login=PASS max-conn=100 http_port 192.168.100.15:82 accel vhost urlgroup=4 acl p82 myport 82 cache_peer_access server_4 allow p82 cache_peer_access server_4 deny all #許可されてないサーバからの接続を全部お断りする http_access deny all