Jun 062012
 

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

10,402 total views, 1 views today

 Posted by at 5:01 pm  Tagged with:

 Leave a Reply

*

© 2011 Indimon Internet Services

Site last updated March 11, 2017 @ 9:57 am; This content last updated January 11, 2013 @ 8:56 pm

Return to Top ▲Return to Top ▲