diff --git a/cmd/root.go b/cmd/root.go index c020bd1..dc24d68 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -104,6 +104,7 @@ func init() { rootCmd.Flags().BoolVar(&config.BlockRemoteCSSAndFonts, "block-remote-css-and-fonts", config.BlockRemoteCSSAndFonts, "Block access to remote CSS & fonts") rootCmd.Flags().StringVar(&config.EnableSpamAssassin, "enable-spamassassin", config.EnableSpamAssassin, "Enable integration with SpamAssassin") rootCmd.Flags().BoolVar(&config.AllowUntrustedTLS, "allow-untrusted-tls", config.AllowUntrustedTLS, "Do not verify HTTPS certificates (link checker & screenshots)") + rootCmd.Flags().BoolVar(&config.DisableHTTPCompression, "disable-http-compression", config.DisableHTTPCompression, "Disable HTTP compression support (web UI & API)") // SMTP server rootCmd.Flags().StringVarP(&config.SMTPListen, "smtp", "s", config.SMTPListen, "SMTP bind interface and port") @@ -237,6 +238,9 @@ func initConfigFromEnv() { if getEnabledFromEnv("MP_ALLOW_UNTRUSTED_TLS") { config.AllowUntrustedTLS = true } + if getEnabledFromEnv("MP_DISABLE_HTTP_COMPRESSION") { + config.DisableHTTPCompression = true + } // SMTP server if len(os.Getenv("MP_SMTP_BIND_ADDR")) > 0 { diff --git a/config/config.go b/config/config.go index 6239408..e161a1b 100644 --- a/config/config.go +++ b/config/config.go @@ -65,6 +65,9 @@ var ( // Webroot to define the base path for the UI and API Webroot = "/" + // DisableHTTPCompression will explicitly disable HTTP compression in the web UI and API + DisableHTTPCompression bool + // SMTPTLSCert file SMTPTLSCert string diff --git a/server/server.go b/server/server.go index 889ba49..eb2a3cd 100644 --- a/server/server.go +++ b/server/server.go @@ -253,7 +253,7 @@ func middleWareFunc(fn http.HandlerFunc) http.HandlerFunc { } } - if !strings.Contains(r.Header.Get("Accept-Encoding"), "gzip") { + if config.DisableHTTPCompression || !strings.Contains(r.Header.Get("Accept-Encoding"), "gzip") { fn(w, r) return }