Skip to content

Commit

Permalink
lighttpd 308 redirect code from http to https
Browse files Browse the repository at this point in the history
github: closes mozilla#139
  • Loading branch information
gstrauss committed May 11, 2023
1 parent ff9835b commit 76a3c66
Showing 1 changed file with 21 additions and 19 deletions.
40 changes: 21 additions & 19 deletions src/templates/partials/lighttpd.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,6 @@
#server.port = 80
$SERVER["socket"] == "[::]:80" { }

{{#if form.hsts}}
$HTTP["scheme"] == "http" {
{{#if (minver "1.4.50" form.serverVersion)}}
url.redirect = ("" => "https://${url.authority}${url.path}${qsa}")
{{else}}
$HTTP["host"] =~ ".*" {
url.redirect = (".*" => "https://%0$0")
}
{{/if}}
}

$HTTP["scheme"] == "https" {
# HTTP Strict Transport Security ({{output.hstsMaxAge}} seconds)
setenv.add-response-header = (
"Strict-Transport-Security" => "max-age={{output.hstsMaxAge}}"
)
}
{{/if}}

{{#if (minver "1.4.56" form.serverVersion)}}
# select one TLS module: "mod_openssl" "mod_mbedtls" "mod_gnutls" "mod_wolfssl" "mod_nss"
#server.modules += ("mod_openssl")
Expand Down Expand Up @@ -103,3 +84,24 @@ $SERVER["socket"] == ":443" {
}
#$SERVER["socket"] == "[::]:443" { ... } # repeat entire $SERVER["socket"] == ":443" { ... } config above for IPv6
{{/if}}

{{#if form.hsts}}
$HTTP["scheme"] == "https" {
# HTTP Strict Transport Security ({{output.hstsMaxAge}} seconds)
setenv.add-response-header = (
"Strict-Transport-Security" => "max-age={{output.hstsMaxAge}}"
)
}
else $HTTP["scheme"] == "http" {
{{#if (minver "1.4.31" form.serverVersion)}}
url.redirect-code = 308
{{/if}}
{{#if (minver "1.4.50" form.serverVersion)}}
url.redirect = ("" => "https://${url.authority}${url.path}${qsa}")
{{else}}
$HTTP["host"] =~ ".*" {
url.redirect = (".*" => "https://%0$0")
}
{{/if}}
}
{{/if}}

0 comments on commit 76a3c66

Please sign in to comment.