日向夏特殊応援部隊

俺様向けメモ

X-REPROXY-CACHE-FORを使いたい人向けショートBK

id:tokuhiromさんとかid:precuredaisukiさんとか既知だろうけども。。。

CREATE SERVICE balancer
  SET listen          = 0.0.0.0:81
  SET role            = reverse_proxy
  SET pool            = myclusters
  SET persist_client  = on
  SET persist_backend = on
  SET verify_backend  = on
  SET enable_reproxy  = true
  SET reproxy_cache_maxsize = 1048576
ENABLE balancer

このreproxy_cache_maxsizeを忘れると見事にX-REPROXY-CACHE-FORがスルーされるので激しく注意!

ってのも、Perlbal::Serviceの中で、

    'reproxy_cache_maxsize' => {
        des => "Set the maximum number of cached reproxy results (X-REPROXY-CACHE-FOR) that may be kept in the service cache. These cached requests take up about 1.25KB of ram each (on Linux x86), but will vary with usage. Perlbal still starts with 0 in the cache and will grow over time. Be careful when adjusting this and watch your ram usage like a hawk.",
        default => 0,
        check_role => "reverse_proxy",
        check_type => "int",
        setter => sub {
            my ($self, $val, $set, $mc) = @_;
            if ($val) {
                $self->{reproxy_cache} ||= Perlbal::Cache->new(maxsize => 1);
                $self->{reproxy_cache}->set_maxsize($val);
            } else {
                $self->{reproxy_cache} = undef;
            }
            return $mc->ok;
        },
    },

と合って、この設定が有効になっていないとそもそもPerlbal::Cacheのインスタンス自体作られないからでした。
見事にはまったー。