From eff8c94e2783a43ceeb8ee8837291b3f7dec064a Mon Sep 17 00:00:00 2001 From: Dean Coakley Date: Mon, 16 Sep 2019 11:23:17 +0100 Subject: [PATCH] Add ServerStatusZones support in vs/vsr --- internal/configs/version2/config.go | 1 + internal/configs/version2/nginx-plus.virtualserver.tmpl | 1 + internal/configs/version2/templates_test.go | 1 + internal/configs/virtualserver.go | 1 + internal/configs/virtualserver_test.go | 3 +++ 5 files changed, 7 insertions(+) diff --git a/internal/configs/version2/config.go b/internal/configs/version2/config.go index 679824f06c..f54612f363 100644 --- a/internal/configs/version2/config.go +++ b/internal/configs/version2/config.go @@ -31,6 +31,7 @@ type UpstreamServer struct { // Server defines a server. type Server struct { ServerName string + StatusZone string ProxyProtocol bool SSL *SSL RedirectToHTTPSBasedOnXForwarderProto bool diff --git a/internal/configs/version2/nginx-plus.virtualserver.tmpl b/internal/configs/version2/nginx-plus.virtualserver.tmpl index 22ca501a05..906ff97fb0 100644 --- a/internal/configs/version2/nginx-plus.virtualserver.tmpl +++ b/internal/configs/version2/nginx-plus.virtualserver.tmpl @@ -41,6 +41,7 @@ server { listen 80{{ if $s.ProxyProtocol }} proxy_protocol{{ end }}; server_name {{ $s.ServerName }}; + status_zone {{ $s.StatusZone }}; {{ with $ssl := $s.SSL }} listen 443 ssl{{ if $ssl.HTTP2 }} http2{{ end }}{{ if $s.ProxyProtocol }} proxy_protocol{{ end }}; diff --git a/internal/configs/version2/templates_test.go b/internal/configs/version2/templates_test.go index d2bba4ccc0..9f45d98ed6 100644 --- a/internal/configs/version2/templates_test.go +++ b/internal/configs/version2/templates_test.go @@ -95,6 +95,7 @@ var virtualServerCfg = VirtualServerConfig{ }, Server: Server{ ServerName: "example.com", + StatusZone: "example.com", ProxyProtocol: true, SSL: &SSL{ HTTP2: true, diff --git a/internal/configs/virtualserver.go b/internal/configs/virtualserver.go index 70c99bc864..f79083066c 100644 --- a/internal/configs/virtualserver.go +++ b/internal/configs/virtualserver.go @@ -326,6 +326,7 @@ func generateVirtualServerConfig(virtualServerEx *VirtualServerEx, tlsPemFileNam StatusMatches: statusMatches, Server: version2.Server{ ServerName: virtualServerEx.VirtualServer.Spec.Host, + StatusZone: virtualServerEx.VirtualServer.Spec.Host, ProxyProtocol: baseCfgParams.ProxyProtocol, SSL: ssl, RedirectToHTTPSBasedOnXForwarderProto: baseCfgParams.RedirectToHTTPS, diff --git a/internal/configs/virtualserver_test.go b/internal/configs/virtualserver_test.go index d3986296aa..dae261d5d7 100644 --- a/internal/configs/virtualserver_test.go +++ b/internal/configs/virtualserver_test.go @@ -255,6 +255,7 @@ func TestGenerateVirtualServerConfig(t *testing.T) { }, Server: version2.Server{ ServerName: "cafe.example.com", + StatusZone: "cafe.example.com", ProxyProtocol: true, RedirectToHTTPSBasedOnXForwarderProto: true, ServerTokens: "off", @@ -456,6 +457,7 @@ func TestGenerateVirtualServerConfigForVirtualServerWithSplits(t *testing.T) { }, Server: version2.Server{ ServerName: "cafe.example.com", + StatusZone: "cafe.example.com", InternalRedirectLocations: []version2.InternalRedirectLocation{ { Path: "/tea", @@ -713,6 +715,7 @@ func TestGenerateVirtualServerConfigForVirtualServerWithRules(t *testing.T) { }, Server: version2.Server{ ServerName: "cafe.example.com", + StatusZone: "cafe.example.com", InternalRedirectLocations: []version2.InternalRedirectLocation{ { Path: "/tea",