[[PageOutline]] * [http://www.squid-cache.org/Versions/v3/3.1/cfgman/ Squid 3.1.22 configuration file] * [http://wiki.squid-cache.org/SquidFaq SquidFaq - Squid Web Proxy Wiki] * http://wiki.squid-cache.org/MultipleInstances * [http://www.namikilab.tuat.ac.jp/~sasada/prog/squidcache.html Squid のキャッシュオブジェクトを解析する] * [http://d.hatena.ne.jp/hideden/20091101/1257061316 nginx+squidで画像キャッシュサーバーの作り方 - Perlとかmemoとか日記とか。] > 仕事で画像キャッシュサーバーを構築した時のメモ。大規模事例の設定例が検索してもあまり見つからなかったので同じような境遇の誰かの参考になれば。 * [http://ysmt.blog21.fc2.com/blog-entry-157.html Freak: Squidのメモ(キャッシュしない設定)] * [http://anubish.com/alog/?p=5 SquidとNicoCacheの連携 | alog] * [http://www.maruko2.com/mw/Squid/%E3%83%8B%E3%82%B3%E3%83%8B%E3%82%B3%E5%8B%95%E7%94%BB%E3%81%AE%E3%82%AD%E3%83%A3%E3%83%83%E3%82%B7%E3%83%A5%E5%85%B1%E6%9C%89_NicoProxy2_%E3%81%A8_Squid_%E3%82%92%E9%80%A3%E6%90%BA%E3%81%95%E3%81%9B%E3%82%8B Squid/ニコニコ動画のキャッシュ共有 NicoProxy2 と Squid を連携させる - maruko2 Note.] * [http://d.hatena.ne.jp/x68kace/20110508/p1 SquidとNicoCache_nlの連携 - ちょっと待っての日記] * [http://blog.nezweb.net/archives/118 Squidでニコ動を高速化&時報回避する方法 » NezBlog] * [http://hp.vector.co.jp/authors/VA022911/tec/centos/squid.htm 水銀室 Squidの多段プロキシ、プロキシルーティングの解説 -CentOS最短構築支援-] = no disk cache = * ~~Ubuntu 12.04 (3.1.19-1ubuntu3.12.04.1)では{{{cache_dir null}}}は使用できない~~ * $ squid3 -v {{{ Squid Cache: Version 3.1.19 configure options: ... '--enable-storeio=ufs,aufs,diskd' ... }}} * http://wiki.squid-cache.org/SquidFaq/ConfiguringSquid#Can_I_make_Squid_proxy_only.2C_without_caching_anything.3F > {{{ > With Squid-2.7, Squid-3.1 and later you can also remove all 'cache_dir' options from your squid.conf to avoid having a cache directory. > }}} * [http://www.squid-cache.org/Doc/config/cache_dir/ squid : cache_dir configuration directive] > * Changes in 3.1 cache_dir > 'null' storage type dropped. In-memory cache is always present. Remove all cache_dir options to prevent on-disk caching. = forward proxy with SSL = * http://wiki.squid-cache.org/Features/HTTPS#Encrypted_browser-Squid_connection > Unfortunately, popular modern browsers do not permit configuration of TLS/SSL encrypted proxy connections. * IE 9/Firefox 17/Chrome 23では、chromeのみ(23.0.1271.97)サポートしている模様 * [http://dev.chromium.org/developers/design-documents/secure-web-proxy Secure Web Proxy - The Chromium Projects] * {{{chrome --proxy-pac-url=D:\ssl.pac}}}のようにして起動する {{{ function FindProxyForURL(url, host) { return "HTTPS proxy.example.jp:8443"; } }}} * インターネットオプション > 接続 > LANの設定 > 自動構成スクリプト に {{{file://D:/ssl.pac}}} のように指定することも出来るが、IE(対応していない全ての接続が不可能になる)やその他のクライアントにも影響が出るため好ましくない * /etc/squid3/squid.conf {{{ https_port 8443 cert=/etc/ssl/ssl.crt key=/etc/ssl/ssl.key options=NO_SSLv2 cipher=ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+SSLv3:+EXP }}} * squid3プロセスはproxyユーザで動作するが、crt, keyファイルとも、chmod o-rしても問題ない(proxyユーザにパーミッションを与える必要は無い) * 信頼されない証明書の場合(俺俺証明書など)、chromeで以下の様なエラーになる {{{ このウェブページにアクセスできません http://www.google.co.jp/ のウェブページは一時的に停止しているか、新しい http://www.google.co.jp/ に移動した可能性があります。 エラー 136 (net::ERR_PROXY_CERTIFICATE_INVALID): 不明なエラーです。 }}} == --enable-ssl == * Ubuntu 12.04のsquid3パッケージは、httpsサイトへのプロクシとしては動作するが、configure --enable-sslされていないため、リビルドが必要 * [http://ubuntuforums.org/showthread.php?t=2049290 (SOLVED) Squid3-3.1.19 on Ubuntu 12.04 - https ssl shebang - Ubuntu Forums] * 必要なパッケージ * mitty@test:~$ sudo aptitude build-dep squid3 {{{ Unable to satisfy the build-depends: Build-Depends: libcap2-dev. }}} * mitty@test:~$ sudo aptitude install -R devscripts * debuildを含むパッケージ -> wiki:TipAndDoc/Linux/Packages#buildpackages * mitty@test:~$ sudo aptitude install -R libcap2-dev {{{ Note: selecting "libcap-dev" instead of the virtual package "libcap2-dev" The following NEW packages will be installed: libcap-dev }}} * 不足していると、{{{debuild -us -uc}}}が以下のエラーで失敗する {{{ dpkg-checkbuilddeps: Unmet build dependencies: libcap2-dev }}} * mitty@test:~$ sudo aptitude install -R libssl-dev * 不足していると、{{{debuild -us -uc}}}が以下のエラーで失敗する {{{ ../../src/ssl/gadgets.h:39:1: error: variable or field 'X509_free_cpp' declared void ../../src/ssl/gadgets.h:39:1: error: 'X509' was not declared in this scope ../../src/ssl/gadgets.h:39:1: error: 'a' was not declared in this scope ../../src/ssl/gadgets.h:40:21: error: 'X509' was not declared in this scope }}} * [http://en.usenet.digipedia.org/thread/17566/16089/ i'm having a problem while compiling squid 3.2.0.12 (since 3.2.0.6) on ubuntu server] * mitty@test:~$ apt-get source squid3 {{{ Get:1 http://ftp.tsukuba.wide.ad.jp/Linux/ubuntu/ precise-updates/main squid3 3.1.19-1ubuntu3.12.04.1 (dsc) [1,912 B] Get:2 http://ftp.tsukuba.wide.ad.jp/Linux/ubuntu/ precise-updates/main squid3 3.1.19-1ubuntu3.12.04.1 (tar) [3,403 kB] Get:3 http://ftp.tsukuba.wide.ad.jp/Linux/ubuntu/ precise-updates/main squid3 3.1.19-1ubuntu3.12.04.1 (diff) [22.1 kB] }}} {{{ squid3-3.1.19/ squid3_3.1.19-1ubuntu3.12.04.1.debian.tar.gz squid3_3.1.19-1ubuntu3.12.04.1.dsc squid3_3.1.19.orig.tar.gz }}} * mitty@test:~$ vim squid3-3.1.19/debian/rules {{{#!diff --- rules 2012-06-20 07:44:17.000000000 +0900 +++ squid3-3.1.19/debian/rules 2012-12-31 06:20:56.484331684 +0900 @@ -35,6 +35,7 @@ --enable-esi \ --enable-zph-qos \ --enable-wccpv2 \ + --enable-ssl \ --disable-translation \ --with-logdir=/var/log/squid3 \ --with-pidfile=/var/run/squid3.pid \ }}} * mitty@test:~/squid3-3.1.19$ debuild -us -uc {{{ squid_3.1.19-1ubuntu3.12.04.1_amd64.deb squid3_3.1.19-1ubuntu3.12.04.1_amd64.deb squid3-common_3.1.19-1ubuntu3.12.04.1_all.deb squid3-dbg_3.1.19-1ubuntu3.12.04.1_amd64.deb squid-cgi_3.1.19-1ubuntu3.12.04.1_amd64.deb squidclient_3.1.19-1ubuntu3.12.04.1_amd64.deb squid-common_3.1.19-1ubuntu3.12.04.1_all.deb }}} == install debs == * 依存パッケージ * mitty@squid:~$ sudo aptitude install -R libcap2 libldap-2.4-2 libltdl7 libsasl2-2 ssl-cert squid-langpack * mitty@squid:~$ sudo dpkg -i squid3_3.1.19-1ubuntu3.12.04.1_amd64.deb squid3-common_3.1.19-1ubuntu3.12.04.1_all.deb * mitty@squid:~$ squid3 -v {{{ Squid Cache: Version 3.1.19 configure options: '--build=x86_64-linux-gnu' '--prefix=/usr' '--includedir=${prefix}/include' '--mandir=${prefix}/share/man' '--infodir=${prefix}/share/info' '--sysconfdir=/etc' '--localstatedir=/var' '--libexecdir=${prefix}/lib/squid3' '--srcdir=.' '--disable-maintainer-mode' '--disable-dependency-tracking' '--disable-silent-rules' '--datadir=/usr/share/squid3' '--sysconfdir=/etc/squid3' '--mandir=/usr/share/man' '--with-cppunit-basedir=/usr' '--enable-inline' '--enable-async-io=8' '--enable-storeio=ufs,aufs,diskd' '--enable-removal-policies=lru,heap' '--enable-delay-pools' '--enable-cache-digests' '--enable-underscores' '--enable-icap-client' '--enable-follow-x-forwarded-for' '--enable-auth=basic,digest,ntlm,negotiate' '--enable-basic-auth-helpers=LDAP,MSNT,NCSA,PAM,SASL,SMB,YP,DB,POP3,getpwnam,squid_radius_auth,multi-domain-NTLM' '--enable-ntlm-auth-helpers=smb_lm,' '--enable-digest-auth-helpers=ldap,password' '--enable-negotiate-auth-helpers=squid_kerb_auth' '--enable-external-acl-helpers=ip_user,ldap_group,session,unix_group,wbinfo_group' '--enable-arp-acl' '--enable-esi' '--enable-zph-qos' '--enable-wccpv2' '--enable-ssl' '--disable-translation' '--with-logdir=/var/log/squid3' '--with-pidfile=/var/run/squid3.pid' '--with-filedescriptors=65536' '--with-large-files' '--with-default-user=proxy' '--enable-linux-netfilter' 'build_alias=x86_64-linux-gnu' 'CFLAGS=-g -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security' 'LDFLAGS=-Wl,-Bsymbolic-functions -fPIE -pie -Wl,-z,relro -Wl,-z,now' 'CPPFLAGS=-D_FORTIFY_SOURCE=2' 'CXXFLAGS=-g -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security' --with-squid=/home/mitty/squid3-3.1.19 }}} * オリジナルのconfigure options * mitty@test:~$ squid3 -v {{{ Squid Cache: Version 3.1.19 configure options: '--build=x86_64-linux-gnu' '--prefix=/usr' '--includedir=${prefix}/include' '--mandir=${prefix}/share/man' '--infodir=${prefix}/share/info' '--sysconfdir=/etc' '--localstatedir=/var' '--libexecdir=${prefix}/lib/squid3' '--srcdir=.' '--disable-maintainer-mode' '--disable-dependency-tracking' '--disable-silent-rules' '--datadir=/usr/share/squid3' '--sysconfdir=/etc/squid3' '--mandir=/usr/share/man' '--with-cppunit-basedir=/usr' '--enable-inline' '--enable-async-io=8' '--enable-storeio=ufs,aufs,diskd' '--enable-removal-policies=lru,heap' '--enable-delay-pools' '--enable-cache-digests' '--enable-underscores' '--enable-icap-client' '--enable-follow-x-forwarded-for' '--enable-auth=basic,digest,ntlm,negotiate' '--enable-basic-auth-helpers=LDAP,MSNT,NCSA,PAM,SASL,SMB,YP,DB,POP3,getpwnam,squid_radius_auth,multi-domain-NTLM' '--enable-ntlm-auth-helpers=smb_lm,' '--enable-digest-auth-helpers=ldap,password' '--enable-negotiate-auth-helpers=squid_kerb_auth' '--enable-external-acl-helpers=ip_user,ldap_group,session,unix_group,wbinfo_group' '--enable-arp-acl' '--enable-esi' '--enable-zph-qos' '--enable-wccpv2' '--disable-translation' '--with-logdir=/var/log/squid3' '--with-pidfile=/var/run/squid3.pid' '--with-filedescriptors=65536' '--with-large-files' '--with-default-user=proxy' '--enable-linux-netfilter' 'build_alias=x86_64-linux-gnu' 'CFLAGS=-g -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security' 'LDFLAGS=-Wl,-Bsymbolic-functions -fPIE -pie -Wl,-z,relro -Wl,-z,now' 'CPPFLAGS=-D_FORTIFY_SOURCE=2' 'CXXFLAGS=-g -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security' --with-squid=/build/buildd/squid3-3.1.19 }}} * sudo aptitude hold squid3 = BASIC authentication = * /etc/squid3/squid.conf {{{ auth_param basic program /usr/lib/squid3/ncsa_auth /path/to/htpasswd.file auth_param basic children 5 auth_param basic realm Squid proxy-caching web server auth_param basic credentialsttl 2 hours acl localnet src 192.168.0.0/24 acl external proxy_auth REQUIRED http_access allow localnet http_access allow external http_access deny all }}} * 192.168.0.0/24からは認証無し * {{{192.168.0.1/24}}}とすると、{{{aclIpParseIpData: WARNING: Netmask masks away part of the specified IP in '192.168.0.1/24'}}}と警告される * それ以外からはBASIC認証 * {{{http_access allow external}}}より先に{{{auth_param}}}が設定されている必要がある {{{ 2012/12/31 18:27:34| Processing: acl external proxy_auth REQUIRED 2012/12/31 18:27:34| Can't use proxy auth because no authentication schemes are fully configured. FATAL: ERROR: Invalid ACL: acl external proxy_auth REQUIRED }}} * /path/to/htpasswd.file はhtpasswdで作成(MD5可) * {{{program /usr/lib/squid3/ncsa_auth}}}は{{{proxy}}}ユーザで動作するため(non-root)、htpasswd.fileのパーミッションは適切に設定する必要がある({{{-rw-r----- 1 root proxy}}}など) = logformat = * [http://www.squid-cache.org/Doc/config/logformat/ squid : logformat configuration directive] * default {{{ logformat squid %ts.%03tu %6tr %>a %Ss/%03>Hs %a %ui %un [%tl] "%rm %ru HTTP/%rv" %>Hs %a %un %Ss:%Sh/%Hs %