diff --git a/docs/user-guide/nginx-configuration/configmap.md b/docs/user-guide/nginx-configuration/configmap.md index e441f5eff..0a63f0cea 100644 --- a/docs/user-guide/nginx-configuration/configmap.md +++ b/docs/user-guide/nginx-configuration/configmap.md @@ -101,8 +101,7 @@ The following table shows a configuration option's name, type, and the default v |[limit-conn-zone-variable](#limit-conn-zone-variable)|string|"$binary_remote_addr"| |[proxy-stream-timeout](#proxy-stream-timeout)|string|"600s"| |[proxy-stream-responses](#proxy-stream-responses)|int|1| -|[bind-address-ipv4](#bind-address-ipv4)|[]string|""| -|[bind-address-ipv6](#bind-address-ipv6)|[]string|""| +|[bind-address](#bind-address)|[]string|""| |[forwarded-for-header](#forwarded-for-header)|string|"X-Forwarded-For"| |[compute-full-forwarded-for](#compute-full-forwarded-for)|bool|"false"| |[proxy-add-original-uri-header](#proxy-add-original-uri-header)|bool|"true"| @@ -586,16 +585,10 @@ Sets the number of datagrams expected from the proxied server in response to the _References:_ [http://nginx.org/en/docs/stream/ngx_stream_proxy_module.html#proxy_responses](http://nginx.org/en/docs/stream/ngx_stream_proxy_module.html#proxy_responses) -## bind-address-ipv4 +## bind-address Sets the addresses on which the server will accept requests instead of *. It should be noted that these addresses must exist in the runtime environment or the controller will crash loop. - -## bind-address-ipv6 - -Sets the addresses on which the server will accept requests instead of *. It should be noted that these addresses must exist in the runtime environment or the controller will crash loop. - - ## forwarded-for-header Sets the header field for identifying the originating IP address of a client. _**default:**_ X-Forwarded-For diff --git a/internal/ingress/controller/template/configmap_test.go b/internal/ingress/controller/template/configmap_test.go index ba05d2694..a88f361aa 100644 --- a/internal/ingress/controller/template/configmap_test.go +++ b/internal/ingress/controller/template/configmap_test.go @@ -17,6 +17,7 @@ limitations under the License. package template import ( + "reflect" "testing" "github.com/kylelemons/godebug/pretty" @@ -75,6 +76,19 @@ func TestMergeConfigMapToStruct(t *testing.T) { t.Errorf("unexpected diff: (-got +want)\n%s", diff) } + to = ReadConfig(conf) + def.BindAddressIpv4 = []string{} + def.BindAddressIpv6 = []string{} + + if !reflect.DeepEqual(to.BindAddressIpv4, []string{"1.1.1.1", "2.2.2.2"}) { + t.Errorf("unexpected bindAddressIpv4") + } + + if !reflect.DeepEqual(to.BindAddressIpv6, []string{"[2001:db8:a0b:12f0::1]", "[3731:54:65fe:2::a7]"}) { + t.Logf("%v", to.BindAddressIpv6) + t.Errorf("unexpected bindAddressIpv6") + } + def = config.NewDefault() to = ReadConfig(map[string]string{}) if diff := pretty.Compare(to, def); diff != "" { diff --git a/internal/ingress/controller/template/template_test.go b/internal/ingress/controller/template/template_test.go index 0c1521245..f42514c9a 100644 --- a/internal/ingress/controller/template/template_test.go +++ b/internal/ingress/controller/template/template_test.go @@ -483,10 +483,22 @@ func TestTemplateWithData(t *testing.T) { t.Errorf("invalid NGINX template: %v", err) } - _, err = ngxTpl.Write(dat) + rt, err := ngxTpl.Write(dat) if err != nil { t.Errorf("invalid NGINX template: %v", err) } + + if !strings.Contains(string(rt), "listen [2001:db8:a0b:12f0::1]") { + t.Errorf("invalid NGINX template, expected IPV6 listen address not present") + } + + if !strings.Contains(string(rt), "listen [3731:54:65fe:2::a7]") { + t.Errorf("invalid NGINX template, expected IPV6 listen address not present") + } + + if !strings.Contains(string(rt), "listen 2.2.2.2") { + t.Errorf("invalid NGINX template, expected IPV4 listen address not present") + } } func BenchmarkTemplateWithData(b *testing.B) { diff --git a/test/data/config.json b/test/data/config.json index bba1c78bb..b023858aa 100644 --- a/test/data/config.json +++ b/test/data/config.json @@ -1,6 +1,10 @@ { "backlogSize": 32768, + "isIPV6Enabled": true, "cfg": { + "disable-ipv6": false, + "bind-address-ipv4": [ "1.1.1.1" , "2.2.2.2"], + "bind-address-ipv6": [ "[2001:db8:a0b:12f0::1]" ,"[3731:54:65fe:2::a7]" ,"[33:33:33::33::33]" ], "backend": { "custom-http-errors": [404], "proxy-buffer-size": "4k",