Useful when you want to redirect the clients to an SSL-version of your site, given that your varnish instance is running behind some SSL-termination point, such as an nginx instance with SSL enabled.
sub vcl_recv { if ( (req.http.host ~ "^(?i)somesite.org" || req.http.host ~ "^(?i)www.somesite.org") && req.http.X-Forwarded-Proto !~ "(?i)https") { set req.http.x-Redir-Url = "https://www.somesite.org" + req.url; error 750 req.http.x-Redir-Url; } } sub vcl_error { if (obj.status == 750) { set obj.http.Location = obj.response; set obj.status = 302; return (deliver); }
Source: https://www.varnish-cache.org/trac/wiki/VCLExampleRedirectInVCL