[Varnish] #1517: HTTPS Redirects
Varnish
varnish-bugs at varnish-cache.org
Thu May 29 02:34:55 CEST 2014
#1517: HTTPS Redirects
---------------------------------+---------------------------
Reporter: shredtechular | Type: documentation
Status: new | Priority: normal
Milestone: Varnish 4.0 release | Component: documentation
Version: 4.0.0 | Severity: normal
Keywords: |
---------------------------------+---------------------------
I've been trying to use the documented example () to setup a redirect for
our website from http to https. This documented example appears to only
work in version 3.x and not 4.0 however.
I've modified the example from:
{{{
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);
}
}}}
to:
{{{
sub vcl_recv {
if ( (req.http.host ~ "^(?i)mysite.com") && req.http.X-Forwarded-Proto
!~ "(?i)https") {
set req.http.x-redir-url = "https://" + req.http.host + req.url;
#error 750 req.http.x-redir-url;
}
}
sub vcl_backend_error {
if (beresp.status == 750) {
# set beresp.http.Location = beresp.response;
set beresp.status = 302;
return (deliver);
}
}
}}}
However, I'm struggling to figure out how to throw the custom error code
to tell Varnish to go to the vcl_backend_error subroutine. In reading
through the documentation it seems like maybe I should use "synth" instead
of "error" but this doesn't seem to be working for me either. If I
uncomment the commented out lines, I'm unable to restart Varnish. Any
ideas or help to do this?
--
Ticket URL: <https://www.varnish-cache.org/trac/ticket/1517>
Varnish <https://varnish-cache.org/>
The Varnish HTTP Accelerator
More information about the varnish-bugs
mailing list