@kyanny's blog

My thoughts, my life. Views/opinions are my own.

squid.conf メモ(acl, http_access, no_cache, always_direct)

squid は acl を単位にして設定していくものらしい。

acl はこんな風に定義する。

acl FOO url_regex foo$ # url に foo$ が含まれる場合にマッチ
acl BAR urlpath_regex -i ^/bar # url の path 部分に ^/bar が含まれる場合にマッチ、大文字小文字の区別なし
acl BAZ referer_regex -i ^http://\.example\.com # リファラが http://example.com を含む場合にマッチ

アクセス制限は http_access で設定する。

acl img urlpath_regex -i ^/img
acl check_referer referer_regex -i ^http://example\.com
http_access deny img !check_referer # img かつ check_referer でない条件にマッチしたときのみ、 deny する(403 を返す)

no_cache, always_direct などの設定もある、がこちらはうまく使えなかった。