Skip to content

Commit

Permalink
feat(pwa): option to add additional headers to NGINX results (#489)
Browse files Browse the repository at this point in the history
* requires PWA 5.0.0 (intershop/intershop-pwa#1456)
  • Loading branch information
Eisie96 authored and shauke committed Nov 30, 2023
1 parent 9064810 commit 0e54311
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 16 deletions.
33 changes: 17 additions & 16 deletions charts/pwa/README.md
Expand Up @@ -17,16 +17,16 @@ $ helm install my-release intershop/pwa-main
The following table provides an overview of the different PWA Helm Chart versions and the minimum required PWA version to use it with.
In addition, the version changes and necessary migration information is provided.

| Chart | PWA | Changes | Migration Information |
| ----- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 0.8.0 | 1.0.0 | <ul><li>New format of declaring (multiple) Ingresses (Split Ingress)</li><li>Shared Redis cache for the nginx containers (requires PWA 5.0.0)</li><li>Monitoring support with Prometheus and Grafana (for development and testing)</li><li>Delay NGINX until PWA SSR is listening</li><li>Configurable update strategy</li><li>Less verbose prefetch job</li></ul> | See [Migration to 0.8.0](https://github.com/intershop/helm-charts/blob/main/charts/pwa/docs/migrate-to-0.8.0.md) in regards to the new format of configuring Ingress and the dropped support of older kubernetes clusters<br/>Configurable `updateStrategy` stays at `RollingUpdate` by default |
| 0.7.0 | 1.0.0 | <ul><li>Re-enabled support for `multi-channel.yaml` and `caching-ignore-params.yaml` source code fallbacks</li><li>Added additional Ingress for domain whitelisting</li><li>Added labels on deployment and pod levels</li> | Removed deprecated configuration options:<ul><li>`upstream.icm`</li><li>`cache.enabled` - was not optional</li><li>`cache.channels`</li></ul>See [Migration to 0.7.0](https://github.com/intershop/helm-charts/blob/main/charts/pwa/docs/migrate-to-0.7.0.md) |
| 0.6.0 | 1.0.0 | Support for Prometheus metrics | |
| 0.5.0 | 1.0.0 | Added prefetch job that can heat up caches | |
| 0.4.0 | 1.0.0 | Support for PWA Hybrid Approach deployment (with ICM 11) | Requires PWA 3.2.0 for Hybrid Approach support |
| 0.3.0 | 1.0.0 | Use new Ingress controller definition | See [Migration to 0.3.0](https://github.com/intershop/helm-charts/blob/main/charts/pwa/docs/migrate-to-0.3.0.md) |
| 0.2.4 | 0.25.0 | Support for `multiChannel`, `cacheIgnoreParams` and `extraEnvVars` for nginx/cache deployment | Missing support for `multi-channel.yaml` and `caching-ignore-params.yaml` source code fallbacks |
| 0.2.3 | 0.25.0 | Legacy Helm Chart 0.2.3 as initial version | |
| Chart | PWA | Changes | Migration Information |
| ----- | ------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 0.8.0 | 1.0.0 | <ul><li>New format of declaring (multiple) Ingresses (Split Ingress)</li><li>Shared Redis cache for the nginx containers (requires PWA 5.0.0)</li><li>Additional result headers configuration (requires PWA 5.0.0)</li><li>Monitoring support with Prometheus and Grafana (for development and testing)</li><li>Delay NGINX until PWA SSR is listening</li><li>Configurable update strategy</li><li>Less verbose prefetch job</li></ul> | See [Migration to 0.8.0](https://github.com/intershop/helm-charts/blob/main/charts/pwa/docs/migrate-to-0.8.0.md) in regards to the new format of configuring Ingress and the dropped support of older kubernetes clusters<br/>Configurable `updateStrategy` stays at `RollingUpdate` by default |
| 0.7.0 | 1.0.0 | <ul><li>Re-enabled support for `multi-channel.yaml` and `caching-ignore-params.yaml` source code fallbacks</li><li>Added additional Ingress for domain whitelisting</li><li>Added labels on deployment and pod levels</li> | Removed deprecated configuration options:<ul><li>`upstream.icm`</li><li>`cache.enabled` - was not optional</li><li>`cache.channels`</li></ul>See [Migration to 0.7.0](https://github.com/intershop/helm-charts/blob/main/charts/pwa/docs/migrate-to-0.7.0.md) |
| 0.6.0 | 1.0.0 | Support for Prometheus metrics | |
| 0.5.0 | 1.0.0 | Added prefetch job that can heat up caches | |
| 0.4.0 | 1.0.0 | Support for PWA Hybrid Approach deployment (with ICM 11) | Requires PWA 3.2.0 for Hybrid Approach support |
| 0.3.0 | 1.0.0 | Use new Ingress controller definition | See [Migration to 0.3.0](https://github.com/intershop/helm-charts/blob/main/charts/pwa/docs/migrate-to-0.3.0.md) |
| 0.2.4 | 0.25.0 | Support for `multiChannel`, `cacheIgnoreParams` and `extraEnvVars` for nginx/cache deployment | Missing support for `multi-channel.yaml` and `caching-ignore-params.yaml` source code fallbacks |
| 0.2.3 | 0.25.0 | Legacy Helm Chart 0.2.3 as initial version | |

## Parameters

Expand All @@ -38,12 +38,13 @@ In addition, the version changes and necessary migration information is provided

### NGINX

| Name | Description | Example Value |
| ------------------------- | ---------------------------------------------------------- | ------------------------------------------------------- |
| `cache.multiChannel` | Multi-channel/site configuration object | `.+:`<br>`channel: default` |
| `cache.cacheIgnoreParams` | NGINX ignore query parameters during caching | `params:`<br>`- utm_source`<br>`- utm_campaign` |
| `cache.extraEnvVars` | Extra environment variables to be set | `extraEnvVars:`<br>`- name: FOO`<br> ` value: BAR` |
| `cache.prefetch` | Specify settings for the prefetch job that heats up caches | `prefetch:`<br>`- host: example.com`<br> ` path: /home` |
| Name | Description | Example Value |
| ------------------------- | ---------------------------------------------------------- | ----------------------------------------------------------------------------- |
| `cache.extraEnvVars` | Extra environment variables to be set | `extraEnvVars:`<br>`- name: FOO`<br> ` value: BAR` |
| `cache.multiChannel` | Multi-channel/site configuration object | `.+:`<br>`channel: default` |
| `cache.cacheIgnoreParams` | NGINX ignore query parameters during caching | `params:`<br>`- utm_source`<br>`- utm_campaign` |
| `cache.additionalHeaders` | Additional result headers configuration | `additionalHeaders:`<br>` headers:`<br>` - X-Frame-Options: 'SAMEORIGIN'` |
| `cache.prefetch` | Specify settings for the prefetch job that heats up caches | `prefetch:`<br>`- host: example.com`<br> ` path: /home` |

Both `cacheIgnoreParams` and `multiChannel` parameters take precedence over any `extraEnvVars` value containing `MULTI_CHANNEL` or `CACHING_IGNORE_PARAMS` variables.

Expand Down
6 changes: 6 additions & 0 deletions charts/pwa/templates/configmap_nginx.yaml
Expand Up @@ -21,3 +21,9 @@ data:
caching-ignore-params.yaml: |-
params: []
{{- end -}}
{{- if .Values.cache.additionalHeaders }}
additional-headers.yaml: {{- .Values.cache.additionalHeaders | toYaml | indent 4}}
{{- else }}
additional-headers.yaml: |-
params: []
{{- end -}}
4 changes: 4 additions & 0 deletions charts/pwa/templates/deployment_cache.yaml
Expand Up @@ -59,6 +59,10 @@ spec:
- name: CACHING_IGNORE_PARAMS_SOURCE
value: "/config/caching-ignore-params.yaml"
{{- end }}
{{- if .Values.cache.additionalHeaders }}
- name: ADDITIONAL_HEADERS_SOURCE
value: "/config/additional-headers.yaml"
{{- end }}
{{- if $nginxMetricsEnabled }}
- name: PROMETHEUS
value: "true"
Expand Down
7 changes: 7 additions & 0 deletions charts/pwa/values.schema.json
Expand Up @@ -194,6 +194,13 @@
"description": "Multi channel/site configuration object",
"additionalProperties": true
},
"additionalHeaders": {
"$id": "#/properties/cache/properties/additionalHeaders",
"type": "string",
"title": "Configure additional headers",
"description": "NGinx adds specified header for every page response",
"additionalProperties": true
},
"extraEnvVars": {
"$id": "#/properties/cache/properties/extraEnvVars",
"type": "array",
Expand Down
10 changes: 10 additions & 0 deletions charts/pwa/values.yaml
Expand Up @@ -120,6 +120,16 @@ cache:
## theme: b2c
multiChannel: ""

####
## @param additional headers configuration object
## additionalHeaders: |
## headers:
## - X-Frame-Options: 'SAMEORIGIN'
#### no additional headers example
## additionalHeaders: |
## headers: []
additionalHeaders: ""

####
## @param extraEnvVars Extra environment variables to be set on NGINX containers
## E.g:
Expand Down

0 comments on commit 0e54311

Please sign in to comment.