diff --git a/config.default.toml b/config.default.toml index c5923454..6eaf3409 100644 --- a/config.default.toml +++ b/config.default.toml @@ -68,3 +68,7 @@ enabled = false max_age = 31536000 include_subdomains = false preload = false + +# Add your own HTTP headers to the index page +[headers] +# X-Example = "Rainbows" diff --git a/config/config.go b/config/config.go index 34f9f6ee..80bf8b49 100644 --- a/config/config.go +++ b/config/config.go @@ -14,6 +14,7 @@ type Config struct { Dev bool HexIP bool VerifyCertificates bool `mapstructure:"verify_certificates"` + Headers map[string]string Defaults *Defaults HTTPS *HTTPS LetsEncrypt *LetsEncrypt diff --git a/server/serve_files.go b/server/serve_files.go index 361f233e..c66eb053 100644 --- a/server/serve_files.go +++ b/server/serve_files.go @@ -323,6 +323,10 @@ func (d *Dispatch) serveIndex(w http.ResponseWriter, r *http.Request) { w.Header().Set("Strict-Transport-Security", hstsHeader) } + for k, v := range d.Config().Headers { + w.Header().Set(k, v) + } + if strings.Contains(r.Header.Get("Accept-Encoding"), "gzip") { w.Header().Set("Content-Encoding", "gzip") w.Header().Set("Content-Length", indexPageLen)