Add default-type as a configurable for default_type

This commit is contained in:
mengqi.wmq 2020-06-21 11:10:51 +08:00
parent 6048e63daa
commit f232a264ab
4 changed files with 18 additions and 1 deletions

View file

@ -671,6 +671,11 @@ type Configuration struct {
// proxy-ssl-* annotations are applied on on location level only in the nginx.conf file
// Default is that those are applied on server level, too
ProxySSLLocationOnly bool `json:"proxy-ssl-location-only"`
// DefaultType Sets the default MIME type of a response.
// http://nginx.org/en/docs/http/ngx_http_core_module.html#default_type
// Default: text/html
DefaultType string `json:"default-type"`
}
// NewDefault returns the default nginx configuration
@ -815,6 +820,7 @@ func NewDefault() Configuration {
NoAuthLocations: "/.well-known/acme-challenge",
GlobalExternalAuth: defGlobalExternalAuth,
ProxySSLLocationOnly: false,
DefaultType: "text/html",
}
if klog.V(5) {

View file

@ -74,6 +74,7 @@ func TestMergeConfigMapToStruct(t *testing.T) {
"nginx-status-ipv6-whitelist": "::1,2001::/16",
"proxy-add-original-uri-header": "false",
"disable-ipv6-dns": "true",
"default-type": "text/plain",
}
def := config.NewDefault()
def.CustomHTTPErrors = []int{300, 400}
@ -97,6 +98,7 @@ func TestMergeConfigMapToStruct(t *testing.T) {
def.ProxyAddOriginalURIHeader = false
def.LuaSharedDicts = defaultLuaSharedDicts
def.DisableIpv6DNS = true
def.DefaultType = "text/plain"
hash, err := hashstructure.Hash(def, &hashstructure.HashOptions{
TagName: "json",