Search code examples
nginxvarnishvarnish-vcl

Varnish: How to efficiently Mass map permanent 302 redirects from a given list


We are in the process of migrating sites and need to setup a large amount of 302 redirects accordingly in Varnish. What is the best way to do this in mass? I am trying to avoid having a large amount of 'if else if' statements if possible...

Essentially what I am looking for is something similar to this, but in Varnish : nginx: How to mass permanent redirect from a given list?

(Varnish Version 4.1.9)


Solution

  • The cleanest way would be to use Vmod-dbrw. This Varnish VMOD implements database-driven rewrite rules.

    For CentOS/RHEL 7, it is available as a RPM package from commercial GetPageSpeed repository here.

    For other distros, you will likely end up compiling it from the source.