Skip to content

Commit

Permalink
Merge pull request #3539 from magda-io/allow-disable-gzip
Browse files Browse the repository at this point in the history
#3538 Add helm chart configuration option allows users to disable gateway auto-gzip response feature
  • Loading branch information
t83714 authored Jun 19, 2024
2 parents 9876e04 + 3a66f58 commit 74e066b
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGELOG

## v4.0.1

- Add helm chart configuration option allows users to disable gateway auto-gzip response feature

## v4.0.0

- Use OpenSearch (v2.14.0) as main search engine
Expand Down
1 change: 1 addition & 0 deletions deploy/helm/internal-charts/gateway/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Kubernetes: `>= 1.14.0-0`
| defaultWebRouteConfig.methods | list | `["GET"]` | array of string. "all" means all methods will be proxied |
| defaultWebRouteConfig.redirectTrailingSlash | bool | `false` | make /xxx auto redirect to /xxxx/ |
| defaultWebRouteConfig.to | string | `""` | the default web router proxy target. Optional. If set, the default web route set via `web` option will be ignored. |
| disableGzip | bool | `false` | By default, response will be auto-gizpped depends on MIME type. Set this to true to disable it. |
| enableAuthEndpoint | bool | `true` | whether or not enable auth endpoint. You can turn it off if you don't need to log into any account. |
| enableCkanRedirection | bool | `false` | wether or not enable CKAN redirection. when it's on, any incoming ckan alike URL will be redirected to the CKAN instance URL that is specified by config option `ckanRedirectionDomain` and `ckanRedirectionPath`. |
| enableHttpsRedirection | bool | `false` | whether or not redirect incoming request using HTTP protocol to HTTPs |
Expand Down
3 changes: 3 additions & 0 deletions deploy/helm/internal-charts/gateway/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ spec:
{{- if .Values.enableCkanRedirection }}
"--enableCkanRedirection", {{ .Values.enableCkanRedirection | quote }},
{{- end }}
{{- if .Values.disableGzip }}
"--disableGzip", {{ .Values.disableGzip | quote }},
{{- end }}
{{- if not (kindIs "invalid" .Values.registryQueryCacheStdTTL) }}
"--registryQueryCacheStdTTL", {{ .Values.registryQueryCacheStdTTL | quote }},
{{- end }}
Expand Down
3 changes: 3 additions & 0 deletions deploy/helm/internal-charts/gateway/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ ckanRedirectionPath:
# -- whether or not redirect incoming request using HTTP protocol to HTTPs
enableHttpsRedirection: false

# -- By default, response will be auto-gizpped depends on MIME type. Set this to true to disable it.
disableGzip: false

# -- a list of authentication plugin config item.
# Each authentication plugin config item can contain the following fields:
# <ul>
Expand Down
4 changes: 2 additions & 2 deletions deploy/helm/local-auth-test-deployment/readme.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# magda-local-auth-test-deployment

![Version: 3.0.4](https://img.shields.io/badge/Version-3.0.4-informational?style=flat-square)
![Version: 4.0.0](https://img.shields.io/badge/Version-4.0.0-informational?style=flat-square)

## Requirements

Kubernetes: `>= 1.14.0-0`

| Repository | Name | Version |
|------------|------|---------|
| file://../magda-core | magda-core | 3.0.4 |
| file://../magda-core | magda-core | 4.0.0 |

## Values

Expand Down
4 changes: 2 additions & 2 deletions deploy/helm/local-deployment/readme.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# magda-local-deployment

![Version: 3.0.4](https://img.shields.io/badge/Version-3.0.4-informational?style=flat-square)
![Version: 4.0.0](https://img.shields.io/badge/Version-4.0.0-informational?style=flat-square)

## Requirements

Kubernetes: `>= 1.14.0-0`

| Repository | Name | Version |
|------------|------|---------|
| oci://ghcr.io/magda-io/charts | magda | 4.0.0-alpha.5 |
| file://../magda | magda | 4.0.0 |
| oci://ghcr.io/magda-io/charts | magda-auth-arcgis | 2.0.1 |
| oci://ghcr.io/magda-io/charts | magda-auth-facebook | 2.0.0 |
| oci://ghcr.io/magda-io/charts | magda-auth-google | 2.0.1 |
Expand Down
6 changes: 5 additions & 1 deletion magda-gateway/src/buildApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export type Config = {
skipAuth?: boolean;
registryQueryCacheMaxKeys: number;
registryQueryCacheStdTTL: number;
disableGzip?: boolean;
};

export default function buildApp(app: express.Application, config: Config) {
Expand Down Expand Up @@ -148,7 +149,10 @@ export default function buildApp(app: express.Application, config: Config) {
app.use(createHttpsRedirectionMiddleware(config.enableHttpsRedirection));

// GZIP responses where appropriate
app.use(compression());
if (!config?.disableGzip) {
app.use(compression());
console.log("Automatic GZIP compression enabled.");
}

// Set sensible secure headers
app.disable("x-powered-by");
Expand Down
6 changes: 6 additions & 0 deletions magda-gateway/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,12 @@ const argv = addJwtSecretFromEnvVar(
type: "boolean",
default: false
})
.option("disableGzip", {
describe:
"By default, response will be auto-gizpped depends on MIME type. Set this to true to disable it.",
type: "boolean",
default: false
})
.option("userId", {
describe:
"The user id to use when making authenticated requests to the registry",
Expand Down

0 comments on commit 74e066b

Please sign in to comment.