Tested in Ubuntu 14 / Debian 8 / Varnish 4.1
If you have configured nginx as SSL proxy for varnish, you could be interested in redirecting requests from HTTP to HTTPS. We are going to suppose this configuration, so first in VCL recv, add this code:
sub vcl_recv { ... if (req.http.X-Forwarded-Proto !~ "(?i)https") { return (synth(750, "")); } ... }
And then in VCL synth:
sub vcl_synth { ... if (resp.status == 750) { set resp.status = 301; set resp.http.Location = "https://domain.com" + req.url; } ... }
Finally reload varnish:
~ $ /etc/init.d/varnish reload