Make it possible for Varnish logs to contain the true scheme used by clients

instead of always reporting http://
This commit is contained in:
Mark Felder 2020-09-30 12:32:54 -05:00
parent cee1883b35
commit 49229107e8

View file

@ -1,3 +1,4 @@
# Recommended varnishncsa logging format: '%h %l %u %t "%m %{X-Forwarded-Proto}i://%{Host}i%U%q %H" %s %b "%{Referer}i" "%{User-agent}i"'
vcl 4.1; vcl 4.1;
import std; import std;
@ -14,8 +15,11 @@ acl purge {
sub vcl_recv { sub vcl_recv {
# Redirect HTTP to HTTPS # Redirect HTTP to HTTPS
if (std.port(server.ip) != 443) { if (std.port(server.ip) != 443) {
set req.http.X-Forwarded-Proto = "http";
set req.http.x-redir = "https://" + req.http.host + req.url; set req.http.x-redir = "https://" + req.http.host + req.url;
return (synth(750, "")); return (synth(750, ""));
} else {
set req.http.X-Forwarded-Proto = "https";
} }
# CHUNKED SUPPORT # CHUNKED SUPPORT