Website migration using Varnish?

Tobias Eichelbrönner tobias.eichelbroenner at
Mon Aug 12 15:13:35 CEST 2013


> My plan is to use varnish in order to fetch Tomcat (or Apache->Tomcat)
> pages from the new application and deliver all urls not found on the new
> application from the old php application.

my first idea would to build a custom error page and redirect all failed
requests from the Java-Website to the old php website.
This is easier if you can use different (sub)domains for the old and the
new page.

The error vcl-code would look something like this (untested)

sub vcl_error {
   if( == "my_java_backend.tld
    set obj.http.Content-Type = "text/html; charset=utf-8";
    set obj.http.Location = "http://my_php_backend.tld/" + req.url;
    set obj.status = 301;#moved permanently



LAMP solutions GmbH
Gostenhofer Hauptstrasse 35
90443 Nuernberg

Amtsgericht Nuernberg: HRB 22366
Geschaeftsfuehrer: Heiko Schubert

Es gelten unsere allgemeinen Geschaeftsbedingungen.

Telefon      : 0911 / 376 516 0
Fax          : 0911 / 376 516 11
E-Mail       : support at
Web          :
Facebook     :
Twitter      :!/lampsolutions

More information about the varnish-misc mailing list