Add gzip-min-length as a configurable
This commit is contained in:
parent
71e35c9100
commit
d48d5a61ae
4 changed files with 12 additions and 1 deletions
|
@ -596,6 +596,10 @@ Enables or disables [HTTP/2](http://nginx.org/en/docs/http/ngx_http_v2_module.ht
|
||||||
|
|
||||||
Sets the gzip Compression Level that will be used. _**default:**_ 5
|
Sets the gzip Compression Level that will be used. _**default:**_ 5
|
||||||
|
|
||||||
|
## gzip-min-length
|
||||||
|
|
||||||
|
Minimum length of responses to be returned to the client before it is eligible for gzip compression, in bytes. _**default:**_ 256
|
||||||
|
|
||||||
## gzip-types
|
## gzip-types
|
||||||
|
|
||||||
Sets the MIME types in addition to "text/html" to compress. The special value "\*" matches any MIME type. Responses with the "text/html" type are always compressed if `[use-gzip](#use-gzip)` is enabled.
|
Sets the MIME types in addition to "text/html" to compress. The special value "\*" matches any MIME type. Responses with the "text/html" type are always compressed if `[use-gzip](#use-gzip)` is enabled.
|
||||||
|
|
|
@ -393,6 +393,10 @@ type Configuration struct {
|
||||||
// gzip Compression Level that will be used
|
// gzip Compression Level that will be used
|
||||||
GzipLevel int `json:"gzip-level,omitempty"`
|
GzipLevel int `json:"gzip-level,omitempty"`
|
||||||
|
|
||||||
|
// Minimum length of responses to be sent to the client before it is eligible
|
||||||
|
// for gzip compression, in bytes.
|
||||||
|
GzipMinLength int `json:"gzip-min-length,omitempty"`
|
||||||
|
|
||||||
// MIME types in addition to "text/html" to compress. The special value “*” matches any MIME type.
|
// MIME types in addition to "text/html" to compress. The special value “*” matches any MIME type.
|
||||||
// Responses with the “text/html” type are always compressed if UseGzip is enabled
|
// Responses with the “text/html” type are always compressed if UseGzip is enabled
|
||||||
GzipTypes string `json:"gzip-types,omitempty"`
|
GzipTypes string `json:"gzip-types,omitempty"`
|
||||||
|
@ -695,6 +699,7 @@ func NewDefault() Configuration {
|
||||||
HSTSPreload: false,
|
HSTSPreload: false,
|
||||||
IgnoreInvalidHeaders: true,
|
IgnoreInvalidHeaders: true,
|
||||||
GzipLevel: 5,
|
GzipLevel: 5,
|
||||||
|
GzipMinLength: 256,
|
||||||
GzipTypes: gzipTypes,
|
GzipTypes: gzipTypes,
|
||||||
KeepAlive: 75,
|
KeepAlive: 75,
|
||||||
KeepAliveRequests: 100,
|
KeepAliveRequests: 100,
|
||||||
|
|
|
@ -65,6 +65,7 @@ func TestMergeConfigMapToStruct(t *testing.T) {
|
||||||
"error-log-path": "/var/log/test/error.log",
|
"error-log-path": "/var/log/test/error.log",
|
||||||
"use-gzip": "true",
|
"use-gzip": "true",
|
||||||
"gzip-level": "9",
|
"gzip-level": "9",
|
||||||
|
"gzip-min-length": "1024",
|
||||||
"gzip-types": "text/html",
|
"gzip-types": "text/html",
|
||||||
"proxy-real-ip-cidr": "1.1.1.1/8,2.2.2.2/24",
|
"proxy-real-ip-cidr": "1.1.1.1/8,2.2.2.2/24",
|
||||||
"bind-address": "1.1.1.1,2.2.2.2,3.3.3,2001:db8:a0b:12f0::1,3731:54:65fe:2::a7,33:33:33::33::33",
|
"bind-address": "1.1.1.1,2.2.2.2,3.3.3,2001:db8:a0b:12f0::1,3731:54:65fe:2::a7,33:33:33::33::33",
|
||||||
|
@ -85,6 +86,7 @@ func TestMergeConfigMapToStruct(t *testing.T) {
|
||||||
def.ProxySendTimeout = 2
|
def.ProxySendTimeout = 2
|
||||||
def.UseProxyProtocol = true
|
def.UseProxyProtocol = true
|
||||||
def.GzipLevel = 9
|
def.GzipLevel = 9
|
||||||
|
def.GzipMinLength = 1024
|
||||||
def.GzipTypes = "text/html"
|
def.GzipTypes = "text/html"
|
||||||
def.ProxyRealIPCIDR = []string{"1.1.1.1/8", "2.2.2.2/24"}
|
def.ProxyRealIPCIDR = []string{"1.1.1.1/8", "2.2.2.2/24"}
|
||||||
def.BindAddressIpv4 = []string{"1.1.1.1", "2.2.2.2"}
|
def.BindAddressIpv4 = []string{"1.1.1.1", "2.2.2.2"}
|
||||||
|
|
|
@ -239,7 +239,7 @@ http {
|
||||||
gzip on;
|
gzip on;
|
||||||
gzip_comp_level {{ $cfg.GzipLevel }};
|
gzip_comp_level {{ $cfg.GzipLevel }};
|
||||||
gzip_http_version 1.1;
|
gzip_http_version 1.1;
|
||||||
gzip_min_length 256;
|
gzip_min_length {{ $cfg.GzipMinLength}};
|
||||||
gzip_types {{ $cfg.GzipTypes }};
|
gzip_types {{ $cfg.GzipTypes }};
|
||||||
gzip_proxied any;
|
gzip_proxied any;
|
||||||
gzip_vary on;
|
gzip_vary on;
|
||||||
|
|
Loading…
Reference in a new issue