zuplo 7.7.11 → 7.7.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Managed Dedicated: Host Header Override"
|
|
3
|
+
sidebar_label: Host Header Override
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
By default, the `Host` header your gateway sends to a backend is derived from
|
|
7
|
+
the URL it connects to. Host header override lets your code send a `Host` header
|
|
8
|
+
that differs from the hostname in the request URL, so the gateway can connect to
|
|
9
|
+
one address while the backend sees the hostname it expects.
|
|
10
|
+
|
|
11
|
+
This setting is only available on [Managed Dedicated](../overview.mdx) instances
|
|
12
|
+
and is off by default.
|
|
13
|
+
|
|
14
|
+
## When to use it
|
|
15
|
+
|
|
16
|
+
Reach for this when the address you connect to and the hostname your backend
|
|
17
|
+
expects aren't the same:
|
|
18
|
+
|
|
19
|
+
- **Virtual-hosted backends.** A single load balancer, ingress controller, or
|
|
20
|
+
web server hosts several sites and picks one based on the `Host` header. Your
|
|
21
|
+
gateway connects to the shared address and names the site it wants.
|
|
22
|
+
- **Private networking.** With
|
|
23
|
+
[private networking](../aws-private-networking.mdx), you reach a backend
|
|
24
|
+
through an internal endpoint or IP whose DNS name doesn't match the public
|
|
25
|
+
hostname the backend is configured for, such as `https://10.0.4.12` with a
|
|
26
|
+
`Host` of `api.acme.com`.
|
|
27
|
+
- **Testing a new backend before DNS moves.** Point the gateway at the new
|
|
28
|
+
origin's address while sending the production `Host` header, so you can
|
|
29
|
+
validate the migration without changing public DNS.
|
|
30
|
+
- **Legacy backends keyed on the hostname.** Applications that route, build
|
|
31
|
+
links, or select a tenant from the `Host` header keep working when the gateway
|
|
32
|
+
sits in front of them.
|
|
33
|
+
|
|
34
|
+
:::caution
|
|
35
|
+
|
|
36
|
+
An incorrect `Host` header can send traffic to the wrong site on a shared
|
|
37
|
+
backend, and some applications trust the header when building redirects and
|
|
38
|
+
links. Enable this setting only if you need it, and set the header to a value
|
|
39
|
+
your code controls rather than one copied from client input.
|
|
40
|
+
|
|
41
|
+
:::
|
|
42
|
+
|
|
43
|
+
## Enable the setting
|
|
44
|
+
|
|
45
|
+
Add `allowHostHeaderOverride` to the `zuplo.jsonc` file at the root of your
|
|
46
|
+
project and deploy:
|
|
47
|
+
|
|
48
|
+
```jsonc
|
|
49
|
+
{
|
|
50
|
+
"version": 1,
|
|
51
|
+
"projectType": "managed-dedicated",
|
|
52
|
+
"allowHostHeaderOverride": true,
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
The setting applies to the whole project. Without it, a `Host` header you set on
|
|
57
|
+
an outbound request is ignored.
|
|
58
|
+
|
|
59
|
+
:::note
|
|
60
|
+
|
|
61
|
+
The `zuplo.jsonc` file isn't editable in the Zuplo Portal. Connect your project
|
|
62
|
+
to [source control](../source-control.mdx) and edit the file there or push a
|
|
63
|
+
local change with git. See
|
|
64
|
+
[Project Configuration](../../programmable-api/zuplo-json.mdx) for the other
|
|
65
|
+
settings this file supports.
|
|
66
|
+
|
|
67
|
+
:::
|
|
68
|
+
|
|
69
|
+
## Example
|
|
70
|
+
|
|
71
|
+
Once the setting is enabled, set the `Host` header on any outbound request. This
|
|
72
|
+
[custom handler](../../handlers/custom-handler.mdx) connects to an internal load
|
|
73
|
+
balancer and tells it which site to serve:
|
|
74
|
+
|
|
75
|
+
```ts
|
|
76
|
+
import { ZuploContext, ZuploRequest, environment } from "@zuplo/runtime";
|
|
77
|
+
|
|
78
|
+
export default async function (request: ZuploRequest, context: ZuploContext) {
|
|
79
|
+
const url = new URL(request.url);
|
|
80
|
+
|
|
81
|
+
return fetch(`${environment.INTERNAL_ORIGIN}${url.pathname}${url.search}`, {
|
|
82
|
+
method: request.method,
|
|
83
|
+
body: request.body,
|
|
84
|
+
headers: {
|
|
85
|
+
...Object.fromEntries(request.headers),
|
|
86
|
+
Host: "api.acme.com",
|
|
87
|
+
},
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
With `INTERNAL_ORIGIN` set to `https://10.0.4.12`, the gateway connects to
|
|
93
|
+
`10.0.4.12` and the backend receives a request for `api.acme.com`.
|
|
@@ -89,11 +89,14 @@ to `false`.
|
|
|
89
89
|
|
|
90
90
|
Allow the Host header to be overridden by the client. This configuration
|
|
91
91
|
defaults to `false`. This is only supported in managed dedicated environments.
|
|
92
|
-
Only enable this setting if you understand the implications.
|
|
92
|
+
Only enable this setting if you understand the implications. See
|
|
93
|
+
[Host Header Override](../dedicated/advanced/host-header-override.mdx) for when
|
|
94
|
+
to use it and an example.
|
|
93
95
|
|
|
94
96
|
```jsonc
|
|
95
97
|
{
|
|
96
98
|
"version": 1,
|
|
99
|
+
"projectType": "managed-dedicated",
|
|
97
100
|
"allowHostHeaderOverride": true,
|
|
98
101
|
}
|
|
99
102
|
```
|
|
@@ -12,24 +12,22 @@ certificates from cert-manager. Before you begin, complete the
|
|
|
12
12
|
Set these variables in the shell that you use for the installation:
|
|
13
13
|
|
|
14
14
|
```bash
|
|
15
|
-
# From the Zuplo portal. See Requirements for instructions.
|
|
16
|
-
export ZUPLO_ACCOUNT_NAME='acme-corp'
|
|
17
15
|
|
|
18
16
|
# Provided by Zuplo during onboarding.
|
|
19
17
|
export ZUPLO_CHART_VERSION='<chart version from onboarding>'
|
|
20
18
|
export ZUPLO_REGISTRY_KEY='<base64 credential from onboarding>'
|
|
21
19
|
|
|
22
|
-
#
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
export
|
|
26
|
-
export
|
|
20
|
+
# Provided by you
|
|
21
|
+
|
|
22
|
+
# These are the credentials to your gateway image registry.
|
|
23
|
+
export BUILDER_REGISTRY_USER='your-example-registry-user'
|
|
24
|
+
export BUILDER_REGISTRY_PASSWORD='your-example-registry-user-pw'
|
|
27
25
|
```
|
|
28
26
|
|
|
29
27
|
## Authenticate to the Zuplo registry
|
|
30
28
|
|
|
31
|
-
The chart is an OCI artifact in Zuplo's registry. The same credential
|
|
32
|
-
chart and the component images.
|
|
29
|
+
The Zuplo Helm chart is an OCI artifact in Zuplo's registry. The same credential
|
|
30
|
+
pulls the chart and the component images.
|
|
33
31
|
|
|
34
32
|
```bash
|
|
35
33
|
printf '%s' "$ZUPLO_REGISTRY_KEY" |
|
|
@@ -52,7 +50,8 @@ account:
|
|
|
52
50
|
|
|
53
51
|
deployments:
|
|
54
52
|
# Parent domain for your APIs. Needs wildcard DNS:
|
|
55
|
-
# *.api.example.com -> your ingress address
|
|
53
|
+
# *.api.example.com -> your ingress address. For example, a preview
|
|
54
|
+
# domain deployment might look like your-preview-branch-abs0ef.api.example.com.
|
|
56
55
|
subdomain: api.example.com
|
|
57
56
|
|
|
58
57
|
managementApi:
|
|
@@ -68,12 +67,11 @@ builder:
|
|
|
68
67
|
secretName: builder-secret
|
|
69
68
|
|
|
70
69
|
cert-manager:
|
|
71
|
-
#
|
|
72
|
-
# is what keeps a wildcard certificate out of the picture.
|
|
70
|
+
# cert-manager is used for managing the lifecyle of each deployment certificate.
|
|
73
71
|
enabled: true
|
|
74
72
|
acme:
|
|
75
|
-
# Required when cert-manager.enabled is true.
|
|
76
|
-
#
|
|
73
|
+
# Required when cert-manager.enabled is true. Used to register the ACME
|
|
74
|
+
# account with the certificate authority.
|
|
77
75
|
email: platform@example.com
|
|
78
76
|
```
|
|
79
77
|
|
|
@@ -91,17 +89,25 @@ zuploImageRegistry:
|
|
|
91
89
|
password: ${ZUPLO_REGISTRY_KEY}
|
|
92
90
|
|
|
93
91
|
builder:
|
|
94
|
-
username:
|
|
95
|
-
password: ${
|
|
92
|
+
username: ${BUILDER_REGISTRY_USER}
|
|
93
|
+
password: ${BUILDER_REGISTRY_PASSWORD}
|
|
96
94
|
EOF
|
|
97
95
|
```
|
|
98
96
|
|
|
99
|
-
:::danger{title="
|
|
97
|
+
:::danger{title="Protect registry credentials"}
|
|
98
|
+
|
|
99
|
+
This file contains registry credentials. Add `zuplo-secrets.yaml` to
|
|
100
|
+
`.gitignore` before creating it, restrict access to the file, and delete the
|
|
101
|
+
local copy after installation. Keep the credentials in your organization's
|
|
102
|
+
secret manager for future upgrades.
|
|
103
|
+
|
|
104
|
+
For automated installations, generate the file from CI secrets or a secret
|
|
105
|
+
manager. If you store the file in Git, encrypt it with a tool such as SOPS and
|
|
106
|
+
decrypt it when running Helm.
|
|
100
107
|
|
|
101
|
-
|
|
102
|
-
Secrets
|
|
103
|
-
|
|
104
|
-
store. Add it to `.gitignore` with your kubeconfig.
|
|
108
|
+
Helm stores these credentials in its release history, and the chart creates
|
|
109
|
+
Kubernetes Secrets from them. Restrict access to these Secrets, including Helm's
|
|
110
|
+
release Secrets.
|
|
105
111
|
|
|
106
112
|
:::
|
|
107
113
|
|
|
@@ -139,7 +145,8 @@ namespaces:
|
|
|
139
145
|
|
|
140
146
|
Without `--version`, Helm selects the most recent chart available at
|
|
141
147
|
installation time. Record the pinned version with `zuplo-values.yaml` so that
|
|
142
|
-
you can review and reproduce upgrades.
|
|
148
|
+
you can review and reproduce upgrades. Your Zuplo solutions architect will tell
|
|
149
|
+
you which version to install.
|
|
143
150
|
|
|
144
151
|
:::
|
|
145
152
|
|
|
@@ -156,17 +163,19 @@ NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S)
|
|
|
156
163
|
zuplo-haproxy-ingress LoadBalancer 10.128.82.11 203.0.113.24 80:31670/TCP,443:31011/TCP 50s
|
|
157
164
|
```
|
|
158
165
|
|
|
159
|
-
Create two DNS A records pointing at
|
|
160
|
-
neither behind a TLS-terminating proxy:
|
|
166
|
+
Create two DNS A records pointing at EXTERNAL-IP, both resolving publicly:
|
|
161
167
|
|
|
162
168
|
| Type | Name | Value |
|
|
163
169
|
| ---- | ------------------------- | -------------- |
|
|
164
170
|
| `A` | `*.api.example.com` | `203.0.113.24` |
|
|
165
171
|
| `A` | `zuplo-admin.example.com` | `203.0.113.24` |
|
|
166
172
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
173
|
+
Certificate issuance requires the HTTP-01 challenge URL at
|
|
174
|
+
http://<hostname>/.well-known/acme-challenge/<token> to be reachable from inside
|
|
175
|
+
the cluster and the public internet. If you use a proxy such as Cloudflare,
|
|
176
|
+
configure it to forward these requests to the cluster without authentication or
|
|
177
|
+
changes to the challenge response. cert-manager checks the URL before asking the
|
|
178
|
+
certificate authority to validate the challenge.
|
|
170
179
|
|
|
171
180
|
## Verify your installation
|
|
172
181
|
|
|
@@ -105,11 +105,18 @@ For HTTP-01 validation, the certificate authority must also reach the ingress on
|
|
|
105
105
|
port 80. If your cluster can't expose port 80 to the public internet, discuss an
|
|
106
106
|
alternative certificate configuration with your Zuplo solutions architect.
|
|
107
107
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
108
|
+
The cluster also needs outbound access to:
|
|
109
|
+
|
|
110
|
+
- Zuplo services for deployment configuration and management API authentication.
|
|
111
|
+
- Zuplo's private container registry and the public registries used by the
|
|
112
|
+
chart's bundled components.
|
|
113
|
+
- Your container registry to push and pull gateway images.
|
|
114
|
+
- Docker Hub and Debian package repositories to build gateway images.
|
|
115
|
+
- Your ACME certificate authority to issue and renew certificates.
|
|
116
|
+
|
|
117
|
+
The Helm chart installs the required components, but the cluster downloads their
|
|
118
|
+
container images and gateway build dependencies. If you restrict outbound
|
|
119
|
+
traffic, allow access to these dependencies.
|
|
113
120
|
|
|
114
121
|
:::note
|
|
115
122
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zuplo",
|
|
3
|
-
"version": "7.7.
|
|
3
|
+
"version": "7.7.12",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "The official Zuplo CLI for local development and platform management",
|
|
6
6
|
"homepage": "https://zuplo.com/docs/cli/overview",
|
|
@@ -32,9 +32,9 @@
|
|
|
32
32
|
"zuplo": "zuplo.js"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@zuplo/cli": "7.7.
|
|
36
|
-
"@zuplo/core": "7.7.
|
|
37
|
-
"@zuplo/runtime": "7.7.
|
|
38
|
-
"@zuplo/test": "7.7.
|
|
35
|
+
"@zuplo/cli": "7.7.12",
|
|
36
|
+
"@zuplo/core": "7.7.12",
|
|
37
|
+
"@zuplo/runtime": "7.7.12",
|
|
38
|
+
"@zuplo/test": "7.7.12"
|
|
39
39
|
}
|
|
40
40
|
}
|