jdecool/scaleway-runtimepublic Fork
⑂ 3eec108
Commits
⬇ Clone ▾
git clone https://git.rickub.com/jdecool/scaleway-runtime.git
git clone ssh://git@rickub.com/jdecool/scaleway-runtime.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

Download ZIP

docs: verify absolute URLs with the host set on ScalewayUnverified

Measured without host, with the function's domain_name and with a custom-domain-like host, plus framework.trusted_hosts; the example README deploys in two applies, the second setting host.
Jérémy DECOOL committed 2026-11-14T15:13:31+01:00 Browse files
3eec108 parent: c945462
modified README.md +1 -0
@@ -125,6 +125,7 @@ Absolute URLs (`UrlGeneratorInterface::ABSOLUTE_URL`, signed URLs, redirects bui
125125 Set it to the function's domain (its `domain_name` on Scaleway) or to its custom domain.
126126 With Terraform, a function cannot reference its own `domain_name` in its variables (the reference would be a cycle): use a custom domain, or set the variable after a first apply.
127127 An application configuring `framework.trusted_hosts` answers every Request with a 400 until the host is set to one of its trusted hosts.
128+Both were [measured on Scaleway](docs/probe-results.md#absolute-urls), forged `X-Forwarded-Host` and `Forwarded` headers never changing the host.
128129
129130 ### Cache and writable directories
130131
@@ -125,6 +125,7 @@ Absolute URLs (`UrlGeneratorInterface::ABSOLUTE_URL`, signed URLs, redirects bui
125 Set it to the function's domain (its `domain_name` on Scaleway) or to its custom domain.125 Set it to the function's domain (its `domain_name` on Scaleway) or to its custom domain.
126 With Terraform, a function cannot reference its own `domain_name` in its variables (the reference would be a cycle): use a custom domain, or set the variable after a first apply.126 With Terraform, a function cannot reference its own `domain_name` in its variables (the reference would be a cycle): use a custom domain, or set the variable after a first apply.
127 An application configuring `framework.trusted_hosts` answers every Request with a 400 until the host is set to one of its trusted hosts.127 An application configuring `framework.trusted_hosts` answers every Request with a 400 until the host is set to one of its trusted hosts.
128+Both were [measured on Scaleway](docs/probe-results.md#absolute-urls), forged `X-Forwarded-Host` and `Forwarded` headers never changing the host.
128 129
129 ### Cache and writable directories130 ### Cache and writable directories
130 131
modified docs/plan.md +3 -2
@@ -56,6 +56,7 @@ Done on 2026-11-14: the repository is on GitHub with CI green, the package is on
5656 Command Invocations were then verified on that deployment through its logs ([probe results](probe-results.md#cron-invocations)): a CRON trigger lands on `POST /`, the `app:greet` arguments with the secret run the command, a wrong secret or an HTTP call do not, and a failing command is logged.
5757 For that, the example logs from the `info` level to stderr, and no longer logs the body of `POST /`, which may hold the secret; `e2e/run.sh` still skips the CRON scenarios against a deployment, the triggers firing hourly and their outcome being in Cockpit only, so the example README documents the manual check.
5858
59-1. Run the example deployment with `host` set, to check absolute URLs.
60-2. Measure what the probe left open: what a deployment with a failing Composer script serves.
59+Absolute URLs were then verified on that deployment, without `host`, with its `domain_name` and with a custom-domain-like value ([probe results](probe-results.md#absolute-urls)): the router, `getUri()` and redirects carry the `host`, never a forged `X-Forwarded-Host`, and `framework.trusted_hosts` answers a 400 until `host` matches it.
60+
61+1. Measure what the probe left open: what a deployment with a failing Composer script serves.
6162 Where logs go was measured on 2026-11-14 ([probe results](probe-results.md#logs)): the runtime's stderr lines reach Cockpit one entry per line, with a `DEBUG - ` prefix and a ` source=user stream=stderr` suffix.
@@ -56,6 +56,7 @@ Done on 2026-11-14: the repository is on GitHub with CI green, the package is on
56 Command Invocations were then verified on that deployment through its logs ([probe results](probe-results.md#cron-invocations)): a CRON trigger lands on `POST /`, the `app:greet` arguments with the secret run the command, a wrong secret or an HTTP call do not, and a failing command is logged.56 Command Invocations were then verified on that deployment through its logs ([probe results](probe-results.md#cron-invocations)): a CRON trigger lands on `POST /`, the `app:greet` arguments with the secret run the command, a wrong secret or an HTTP call do not, and a failing command is logged.
57 For that, the example logs from the `info` level to stderr, and no longer logs the body of `POST /`, which may hold the secret; `e2e/run.sh` still skips the CRON scenarios against a deployment, the triggers firing hourly and their outcome being in Cockpit only, so the example README documents the manual check.57 For that, the example logs from the `info` level to stderr, and no longer logs the body of `POST /`, which may hold the secret; `e2e/run.sh` still skips the CRON scenarios against a deployment, the triggers firing hourly and their outcome being in Cockpit only, so the example README documents the manual check.
58 58
59-1. Run the example deployment with `host` set, to check absolute URLs.59+Absolute URLs were then verified on that deployment, without `host`, with its `domain_name` and with a custom-domain-like value ([probe results](probe-results.md#absolute-urls)): the router, `getUri()` and redirects carry the `host`, never a forged `X-Forwarded-Host`, and `framework.trusted_hosts` answers a 400 until `host` matches it.
60-2. Measure what the probe left open: what a deployment with a failing Composer script serves.60+
61+1. Measure what the probe left open: what a deployment with a failing Composer script serves.
61 Where logs go was measured on 2026-11-14 ([probe results](probe-results.md#logs)): the runtime's stderr lines reach Cockpit one entry per line, with a `DEBUG - ` prefix and a ` source=user stream=stderr` suffix.62 Where logs go was measured on 2026-11-14 ([probe results](probe-results.md#logs)): the runtime's stderr lines reach Cockpit one entry per line, with a `DEBUG - ` prefix and a ` source=user stream=stderr` suffix.
modified docs/probe-results.md +14 -0
@@ -57,6 +57,20 @@ Headers sent by the client:
5757 | `X-Real-Ip`, `X-Envoy-External-Address`, `X-Request-Id`, `K-Proxy-Request` | Overwritten by the platform |
5858 | `Host` | Not forwarded to the function (an unknown host routes to a 404) |
5959
60+## Absolute URLs
61+
62+Measured on 2026-11-14 with the example deployed on `php85` (runtime `2bca487`, whose host handling is the current one), its `GET /urls` answering the router's `ABSOLUTE_URL`, `getUri()` and `getSchemeAndHttpHost()`, and its `GET /redirect` a `RedirectResponse` to an absolute route URL.
63+Each request also sent `X-Forwarded-Host: spoofed.example`, `Forwarded: host=spoofed.example` and `X-Forwarded-Port: 8443`, which never showed in any URL.
64+
65+| `host` (`SCALEWAY_HOST`) | `GET /urls?a=1` | `GET /redirect` |
66+| --- | --- | --- |
67+| Unset | `https://localhost/hello?name=url`, `https://localhost/urls?a=1`, `https://localhost` | `302`, `Location: https://localhost/hello?name=redirect` |
68+| The function's `domain_name`, after a first apply | `https://<domain_name>/hello?name=url`, `https://<domain_name>/urls?a=1`, `https://<domain_name>` | `302`, `Location: https://<domain_name>/hello?name=redirect`, which `curl -L` follows to `{"message":"Hello redirect!"}` |
69+| `api.example.com`, standing for a custom domain | `https://api.example.com/hello?name=url`, `https://api.example.com/urls?a=1`, `https://api.example.com` | `302`, `Location: https://api.example.com/hello?name=redirect` |
70+
71+Changing `host` is an in-place update of the function; the new value served within a minute or so.
72+With `framework.trusted_hosts: ['^api\.example\.com$']`, `host` set to `api.example.com` answered `200`, and `host` unset answered every Request with a `400`, forged `X-Forwarded-Host: api.example.com` and `Forwarded: host=api.example.com` not helping, and a `Host: api.example.com` routing to the platform's `404`.
73+
6074 ## CRON Event
6175
6276 ```json
@@ -57,6 +57,20 @@ Headers sent by the client:
57 | `X-Real-Ip`, `X-Envoy-External-Address`, `X-Request-Id`, `K-Proxy-Request` | Overwritten by the platform |57 | `X-Real-Ip`, `X-Envoy-External-Address`, `X-Request-Id`, `K-Proxy-Request` | Overwritten by the platform |
58 | `Host` | Not forwarded to the function (an unknown host routes to a 404) |58 | `Host` | Not forwarded to the function (an unknown host routes to a 404) |
59 59
60+## Absolute URLs
61+
62+Measured on 2026-11-14 with the example deployed on `php85` (runtime `2bca487`, whose host handling is the current one), its `GET /urls` answering the router's `ABSOLUTE_URL`, `getUri()` and `getSchemeAndHttpHost()`, and its `GET /redirect` a `RedirectResponse` to an absolute route URL.
63+Each request also sent `X-Forwarded-Host: spoofed.example`, `Forwarded: host=spoofed.example` and `X-Forwarded-Port: 8443`, which never showed in any URL.
64+
65+| `host` (`SCALEWAY_HOST`) | `GET /urls?a=1` | `GET /redirect` |
66+| --- | --- | --- |
67+| Unset | `https://localhost/hello?name=url`, `https://localhost/urls?a=1`, `https://localhost` | `302`, `Location: https://localhost/hello?name=redirect` |
68+| The function's `domain_name`, after a first apply | `https://<domain_name>/hello?name=url`, `https://<domain_name>/urls?a=1`, `https://<domain_name>` | `302`, `Location: https://<domain_name>/hello?name=redirect`, which `curl -L` follows to `{"message":"Hello redirect!"}` |
69+| `api.example.com`, standing for a custom domain | `https://api.example.com/hello?name=url`, `https://api.example.com/urls?a=1`, `https://api.example.com` | `302`, `Location: https://api.example.com/hello?name=redirect` |
70+
71+Changing `host` is an in-place update of the function; the new value served within a minute or so.
72+With `framework.trusted_hosts: ['^api\.example\.com$']`, `host` set to `api.example.com` answered `200`, and `host` unset answered every Request with a `400`, forged `X-Forwarded-Host: api.example.com` and `Forwarded: host=api.example.com` not helping, and a `Host: api.example.com` routing to the platform's `404`.
73+
60 ## CRON Event74 ## CRON Event
61 75
62 ```json76 ```json
modified example/README.md +10 -4
@@ -10,6 +10,8 @@ A minimal Symfony application running on Scaleway Serverless Functions through `
1010 | `GET /binary` | A binary response (bytes 0 to 255) |
1111 | `GET /stream` | A streamed response, buffered into one Function Response |
1212 | `GET /counter` | A per-process invocation counter: it keeps growing while a Warm Process serves the Invocations |
13+| `GET /urls` | The absolute URLs the application builds: from the router, `getUri()` and `getSchemeAndHttpHost()` |
14+| `GET /redirect` | A redirect to an absolute route URL |
1315 | `POST /` | Where CRON Invocations land, with the trigger's arguments as JSON body |
1416
1517 Its `post-install-cmd` warms the prod cache when Scaleway installs the dependencies at deploy time, as the warmup needs no secret; without it, the first Invocation of each Warm Process builds the cache.
@@ -74,13 +76,17 @@ cd example
7476 vendor/bin/scaleway-package
7577 export SCW_ACCESS_KEY=... SCW_SECRET_KEY=... SCW_DEFAULT_PROJECT_ID=...
7678 terraform -chdir=terraform init
77-export SCALEWAY_CRON_SECRET=$(openssl rand -hex 32)
78-terraform -chdir=terraform apply -var app_secret="$(openssl rand -hex 16)" -var cron_secret="$SCALEWAY_CRON_SECRET"
79-e2e/run.sh "$(terraform -chdir=terraform output -raw endpoint)"
79+export TF_VAR_app_secret=$(openssl rand -hex 16) SCALEWAY_CRON_SECRET=$(openssl rand -hex 32)
80+export TF_VAR_cron_secret=$SCALEWAY_CRON_SECRET
81+terraform -chdir=terraform apply
82+endpoint=$(terraform -chdir=terraform output -raw endpoint)
83+terraform -chdir=terraform apply -var host="${endpoint#https://}"
84+SCALEWAY_HOST=${endpoint#https://} e2e/run.sh "$endpoint"
8085 terraform -chdir=terraform destroy
8186 ```
8287
83-Rerun `scaleway-package` and `terraform apply` to deploy a new version.
88+Rerun `scaleway-package` and `terraform apply` (with the same `host`) to deploy a new version.
89+`e2e/run.sh` checks that absolute URLs carry `SCALEWAY_HOST`, `localhost` when it is unset, as for a deployment without `host`.
8490 Against a deployment, `e2e/run.sh` skips the CRON scenarios, as only the platform triggers CRON Invocations.
8591 Check them in the [logs](../README.md#logs) instead, after the triggers ran (at minutes 0 and 30): each one leaves its line, the second showing that `app:greet` ran as a Command Invocation.
8692
@@ -10,6 +10,8 @@ A minimal Symfony application running on Scaleway Serverless Functions through `
10 | `GET /binary` | A binary response (bytes 0 to 255) |10 | `GET /binary` | A binary response (bytes 0 to 255) |
11 | `GET /stream` | A streamed response, buffered into one Function Response |11 | `GET /stream` | A streamed response, buffered into one Function Response |
12 | `GET /counter` | A per-process invocation counter: it keeps growing while a Warm Process serves the Invocations |12 | `GET /counter` | A per-process invocation counter: it keeps growing while a Warm Process serves the Invocations |
13+| `GET /urls` | The absolute URLs the application builds: from the router, `getUri()` and `getSchemeAndHttpHost()` |
14+| `GET /redirect` | A redirect to an absolute route URL |
13 | `POST /` | Where CRON Invocations land, with the trigger's arguments as JSON body |15 | `POST /` | Where CRON Invocations land, with the trigger's arguments as JSON body |
14 16
15 Its `post-install-cmd` warms the prod cache when Scaleway installs the dependencies at deploy time, as the warmup needs no secret; without it, the first Invocation of each Warm Process builds the cache.17 Its `post-install-cmd` warms the prod cache when Scaleway installs the dependencies at deploy time, as the warmup needs no secret; without it, the first Invocation of each Warm Process builds the cache.
@@ -74,13 +76,17 @@ cd example
74 vendor/bin/scaleway-package76 vendor/bin/scaleway-package
75 export SCW_ACCESS_KEY=... SCW_SECRET_KEY=... SCW_DEFAULT_PROJECT_ID=...77 export SCW_ACCESS_KEY=... SCW_SECRET_KEY=... SCW_DEFAULT_PROJECT_ID=...
76 terraform -chdir=terraform init78 terraform -chdir=terraform init
77-export SCALEWAY_CRON_SECRET=$(openssl rand -hex 32)79+export TF_VAR_app_secret=$(openssl rand -hex 16) SCALEWAY_CRON_SECRET=$(openssl rand -hex 32)
78-terraform -chdir=terraform apply -var app_secret="$(openssl rand -hex 16)" -var cron_secret="$SCALEWAY_CRON_SECRET"80+export TF_VAR_cron_secret=$SCALEWAY_CRON_SECRET
79-e2e/run.sh "$(terraform -chdir=terraform output -raw endpoint)"81+terraform -chdir=terraform apply
82+endpoint=$(terraform -chdir=terraform output -raw endpoint)
83+terraform -chdir=terraform apply -var host="${endpoint#https://}"
84+SCALEWAY_HOST=${endpoint#https://} e2e/run.sh "$endpoint"
80 terraform -chdir=terraform destroy85 terraform -chdir=terraform destroy
81 ```86 ```
82 87
83-Rerun `scaleway-package` and `terraform apply` to deploy a new version.88+Rerun `scaleway-package` and `terraform apply` (with the same `host`) to deploy a new version.
89+`e2e/run.sh` checks that absolute URLs carry `SCALEWAY_HOST`, `localhost` when it is unset, as for a deployment without `host`.
84 Against a deployment, `e2e/run.sh` skips the CRON scenarios, as only the platform triggers CRON Invocations.90 Against a deployment, `e2e/run.sh` skips the CRON scenarios, as only the platform triggers CRON Invocations.
85 Check them in the [logs](../README.md#logs) instead, after the triggers ran (at minutes 0 and 30): each one leaves its line, the second showing that `app:greet` ran as a Command Invocation.91 Check them in the [logs](../README.md#logs) instead, after the triggers ran (at minutes 0 and 30): each one leaves its line, the second showing that `app:greet` ran as a Command Invocation.
86 92