Skip to content

Commit c34cf11

Browse files
authored
Merge branch 'main' into chore/update-ci
2 parents 58d6433 + fab521e commit c34cf11

File tree

18 files changed

+7124
-5896
lines changed

18 files changed

+7124
-5896
lines changed

deployments/common/crds/k8s.nginx.org_virtualservers.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ spec:
8787
recordType:
8888
type: string
8989
gunzip:
90-
type: string
90+
type: boolean
9191
host:
9292
type: string
9393
http-snippets:

deployments/helm-chart/crds/k8s.nginx.org_virtualservers.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ spec:
8787
recordType:
8888
type: string
8989
gunzip:
90-
type: string
90+
type: boolean
9191
host:
9292
type: string
9393
http-snippets:

docs/content/configuration/virtualserver-and-virtualserverroute-resources.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ spec:
5454
| ---| ---| ---| --- |
5555
|``host`` | The host (domain name) of the server. Must be a valid subdomain as defined in RFC 1123, such as ``my-app`` or ``hello.example.com``. When using a wildcard domain like ``*.example.com`` the domain must be contained in double quotes. The ``host`` value needs to be unique among all Ingress and VirtualServer resources. See also [Handling Host and Listener Collisions](/nginx-ingress-controller/configuration/handling-host-and-listener-collisions). | ``string`` | Yes |
5656
|``tls`` | The TLS termination configuration. | [tls](#virtualservertls) | No |
57-
|``gunzip`` | Enables or disables [decompression](https://docs.nginx.com/nginx/admin-guide/web-server/compression/) of gzipped responses for clients. Allowed values are: "on" or "off". If the ``gunzip`` value is not set, it defaults to ``off``. | ``string`` | No |
57+
|``gunzip`` | Enables or disables [decompression](https://docs.nginx.com/nginx/admin-guide/web-server/compression/) of gzipped responses for clients. Allowed values “on”/“off”, “true”/“false” or “yes”/“no”. If the ``gunzip`` value is not set, it defaults to ``off``. | ``boolean`` | No |
5858
|``externalDNS`` | The externalDNS configuration for a VirtualServer. | [externalDNS](#virtualserverexternaldns) | No |
5959
|``dos`` | A reference to a DosProtectedResource, setting this enables DOS protection of the VirtualServer. | ``string`` | No |
6060
|``policies`` | A list of policies. | [[]policy](#virtualserverpolicy) | No |

examples/custom-resources/jwt/README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,21 @@ Date: 10/Sep/2020:18:20:03 +0000
6767
URI: /
6868
Request ID: db2c07ce640755ccbe9f666d16f85620
6969
```
70+
71+
> **Note**:<br>
72+
You can add a ``gunzip`` option to the VirtualServer spec. Adding the ``gunzip`` allows NIC to decompress responses where an item
73+
like a JWT token is compressed by the IdP.<br>
74+
If an IdP compresses a JWT token and NIC is not configured to decompress responses (``gunzip`` not set to ``on``), the error "invalid JWK set while sending to client" is generated by NIC.<br>
75+
When the ``gunzip`` value is set to ``on``, NIC automatically decompresses responses with “Content-Encoding: gzip” header.
76+
77+
Example:
78+
```yaml
79+
apiVersion: k8s.nginx.org/v1
80+
kind: VirtualServer
81+
metadata:
82+
name: webapp
83+
spec:
84+
host: webapp.example.com
85+
gunzip: on
86+
...
87+
```

internal/configs/version2/http.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ type Server struct {
8181
VSNamespace string
8282
VSName string
8383
DisableIPV6 bool
84-
Gunzip string
84+
Gunzip bool
8585
}
8686

8787
// SSL defines SSL configuration for a server.

internal/configs/version2/nginx-plus.virtualserver.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ proxy_cache_path /var/cache/nginx/jwks_uri_{{$s.VSName}} levels=1 keys_zone=jwks
6363
{{ end }}
6464

6565
server {
66-
{{ if (eq $s.Gunzip "on") }}gunzip {{ $s.Gunzip }};{{end}}
66+
{{ if $s.Gunzip }}gunzip on;{{end}}
6767
listen 80{{ if $s.ProxyProtocol }} proxy_protocol{{ end }};
6868
{{ if not $s.DisableIPV6 }}listen [::]:80{{ if $s.ProxyProtocol }} proxy_protocol{{ end }};{{ end }}
6969

internal/configs/version2/nginx.virtualserver.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ limit_req_zone {{ $z.Key }} zone={{ $z.ZoneName }}:{{ $z.ZoneSize }} rate={{ $z.
4040

4141
{{ $s := .Server }}
4242
server {
43-
{{ if (eq $s.Gunzip "on") }}gunzip {{ $s.Gunzip }};{{end}}
43+
{{ if $s.Gunzip }}gunzip on;{{end}}
4444
listen 80{{ if $s.ProxyProtocol }} proxy_protocol{{ end }};
4545
{{ if not $s.DisableIPV6 }}listen [::]:80{{ if $s.ProxyProtocol }} proxy_protocol{{ end }};{{ end }}
4646

internal/configs/version2/templates_test.go

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package version2
22

33
import (
4+
"bytes"
45
"testing"
56
)
67

@@ -38,6 +39,9 @@ func TestExecuteVirtualServerTemplate_RendersTemplateWithServerGunzipOn(t *testi
3839
if err != nil {
3940
t.Error(err)
4041
}
42+
if !bytes.Contains(got, []byte("gunzip on;")) {
43+
t.Error("want `gunzip on` directive, got no directive")
44+
}
4145
t.Log(string(got))
4246
}
4347

@@ -51,32 +55,25 @@ func TestExecuteVirtualServerTemplate_RendersTemplateWithServerGunzipOff(t *test
5155
if err != nil {
5256
t.Error(err)
5357
}
54-
t.Log(string(got))
55-
}
56-
57-
func TestExecuteVirtualServerTemplate_RendersTemplateWithServerGunzipEmpty(t *testing.T) {
58-
t.Parallel()
59-
executor, err := NewTemplateExecutor(nginxPlusVirtualServerTmpl, nginxPlusTransportServerTmpl)
60-
if err != nil {
61-
t.Fatal(err)
62-
}
63-
got, err := executor.ExecuteVirtualServerTemplate(&virtualServerCfgWithEmptyGunzip)
64-
if err != nil {
65-
t.Error(err)
58+
if bytes.Contains(got, []byte("gunzip on;")) {
59+
t.Error("want no directive, got `gunzip on`")
6660
}
6761
t.Log(string(got))
6862
}
6963

70-
func TestExecuteVirtualServerTemplate_RendersTemplateWithoutServerGunzip(t *testing.T) {
64+
func TestExecuteVirtualServerTemplate_RendersTemplateWithServerGunzipNotSet(t *testing.T) {
7165
t.Parallel()
7266
executor, err := NewTemplateExecutor(nginxPlusVirtualServerTmpl, nginxPlusTransportServerTmpl)
7367
if err != nil {
7468
t.Fatal(err)
7569
}
76-
got, err := executor.ExecuteVirtualServerTemplate(&virtualServerCfg)
70+
got, err := executor.ExecuteVirtualServerTemplate(&virtualServerCfgWithGunzipNotSet)
7771
if err != nil {
7872
t.Error(err)
7973
}
74+
if bytes.Contains(got, []byte("gunzip on;")) {
75+
t.Error("want no directive, got `gunzip on` directive")
76+
}
8077
t.Log(string(got))
8178
}
8279

@@ -853,7 +850,7 @@ var (
853850
},
854851
},
855852
},
856-
Gunzip: "on",
853+
Gunzip: true,
857854
},
858855
}
859856

@@ -1199,11 +1196,11 @@ var (
11991196
},
12001197
},
12011198
},
1202-
Gunzip: "off",
1199+
Gunzip: false,
12031200
},
12041201
}
12051202

1206-
virtualServerCfgWithEmptyGunzip = VirtualServerConfig{
1203+
virtualServerCfgWithGunzipNotSet = VirtualServerConfig{
12071204
LimitReqZones: []LimitReqZone{
12081205
{
12091206
ZoneName: "pol_rl_test_test_test", Rate: "10r/s", ZoneSize: "10m", Key: "$url",
@@ -1545,7 +1542,6 @@ var (
15451542
},
15461543
},
15471544
},
1548-
Gunzip: "",
15491545
},
15501546
}
15511547

internal/configs/virtualserver.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -684,6 +684,7 @@ func (vsc *virtualServerConfigurator) GenerateVirtualServerConfig(
684684
HTTPSnippets: httpSnippets,
685685
Server: version2.Server{
686686
ServerName: vsEx.VirtualServer.Spec.Host,
687+
Gunzip: vsEx.VirtualServer.Spec.Gunzip,
687688
StatusZone: vsEx.VirtualServer.Spec.Host,
688689
ProxyProtocol: vsc.cfgParams.ProxyProtocol,
689690
SSL: sslConfig,

0 commit comments

Comments
 (0)