Fix #3522: Enable HSTS.

This commit is contained in:
evazion
2018-01-28 19:57:45 -06:00
parent 2fd91bfa20
commit 09462aefeb
2 changed files with 31 additions and 0 deletions

View File

@@ -198,6 +198,26 @@ module Danbooru
1.week.ago
end
# Permanently redirect all HTTP requests to HTTPS.
#
# https://en.wikipedia.org/wiki/HTTP_Strict_Transport_Security
# http://api.rubyonrails.org/classes/ActionDispatch/SSL.html
def ssl_options
{
redirect: { exclude: ->(request) { request.subdomain == "insecure" } },
hsts: {
expires: 1.year,
preload: true,
subdomains: false,
},
}
end
# Disable the forced use of HTTPS.
# def ssl_options
# false
# end
# The name of the server the app is hosted on.
def server_host
Socket.gethostname