-
-
Notifications
You must be signed in to change notification settings - Fork 6
feat: add support for reverse proxy header handling #835
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
1b12235
Add TrustedProxy type for validating trusted reverse proxy entries
razvan 37c0bc3
Add trustedProxies field to the webserver role config
razvan 455d3c6
Validate trustedProxies during cluster validation
razvan f9857e7
Enable api-server proxy headers when trusted proxies are configured
razvan 27ecc17
Configure which reverse proxies the api-server trusts
razvan dcfb924
Document running the Airflow webserver behind a reverse proxy
razvan 7e9c567
Add integration test coverage for trusted proxies
razvan 0ff22b3
Gate trusted-proxies kuttl assertions for Airflow 2.x scenarios
razvan 4852379
Fix trusted-proxies review findings: host-bit CIDRs, sole-wildcard ru…
razvan 30c51ec
Docs: fix reverse-proxy guidance to avoid invalid trustedProxies entries
razvan f82c7be
Reject trusted-proxy prefix lengths with a leading sign
razvan 56960e9
Tone down the verbosity of the CRD field doc
razvan 066898f
Remove comment verbosity
razvan 98f8703
Enable ProxyFix environment variables for Airflow 2
razvan d0de7b6
Expand OIDC integration test with reverse proxy settings
razvan df076bf
More comment cleanup
razvan e75633d
Fix oidc test on OpenShift and use '*' for trusted proxies
razvan 92e7149
Merge branch 'main' into feat/trusted-proxies
razvan 0365d70
Reduce code comment verbosity
razvan 92550f8
Implement review feedback: better error messages
razvan b31a80b
Merge branch 'main' into feat/trusted-proxies
razvan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| = Running behind a reverse proxy | ||
| :description: Configure which reverse proxies the Airflow webserver trusts X-Forwarded-* headers from. | ||
|
|
||
| When the Airflow webserver is reached through an ingress controller or another reverse proxy, every | ||
| request arrives from the proxy rather than from the client. Unless the webserver is told to trust | ||
| the proxy, it records the proxy's address as the client address, and it treats a TLS-terminated | ||
| request as plain HTTP -- which, among other things, means session cookies are not marked as | ||
| `Secure`. | ||
|
|
||
| Set `trustedProxies` on the webserver role to the addresses your proxy sends requests from: | ||
|
|
||
| [source,yaml] | ||
| ---- | ||
| spec: | ||
| webservers: | ||
| roleConfig: | ||
| listenerClass: external-stable | ||
| trustedProxies: | ||
| - 10.244.0.0/16 # <1> | ||
| roleGroups: | ||
| default: | ||
| replicas: 1 | ||
| ---- | ||
|
|
||
| <1> IP addresses (`10.0.0.1`), CIDR networks (`10.244.0.0/16`), and `*` are accepted. `*` must be | ||
| the only entry in the list: combining it with other entries is rejected, since it would silently | ||
| degrade to trusting only those other entries. | ||
|
|
||
| On Airflow 3.x the operator starts the api-server with `--proxy-headers` and restricts the headers | ||
| to the listed peers. Airflow 2.x has no equivalent restriction: see | ||
| <<airflow-2-x-has-no-peer-restriction>>. | ||
|
|
||
| == Choosing the value | ||
|
|
||
| Use the narrowest range that covers your proxy, and give it as a network address (host bits zero, | ||
| e.g. `10.244.0.0/16`) or as a bare host IP (no `/prefix` at all, e.g. `10.244.0.5`). | ||
|
|
||
| For an ingress controller running in the cluster, list the Pod addresses as bare host IPs rather | ||
| than guessing a network: | ||
|
|
||
| [source,bash] | ||
| ---- | ||
| kubectl get pods -n ingress-nginx -o jsonpath='{.items[*].status.podIP}' | ||
| ---- | ||
|
|
||
| If your ingress controller's Pods share a known, stable CIDR (for example a dedicated node pool or | ||
| a documented Pod CIDR range for that namespace), you can use that network instead -- but confirm it | ||
| against your cluster's actual CNI configuration rather than inferring it from a single Pod IP, | ||
| since a Pod IP alone does not tell you where the network boundary is. | ||
|
|
||
| `*` trusts forwarded headers from any peer that can reach the webserver. Only use it when access | ||
| to the webserver is restricted by other means -- with a `cluster-internal` or | ||
| `external-unstable` ListenerClass, clients reach the Pod directly and can set the headers | ||
| themselves. | ||
|
|
||
| WARNING: A peer that is trusted can set the client address that ends up in the webserver's access | ||
| log. Do not list ranges wider than the proxies you operate. | ||
|
|
||
| [#airflow-2-x-has-no-peer-restriction] | ||
| == Airflow 2.x has no peer restriction | ||
|
|
||
| Airflow 2.x's webserver has no analogue support for trusted network addresses. Once enabled, it | ||
| unconditionally trusts `X-Forwarded-*` from *any* peer, the same as `trustedProxies: ["*"]` on 3.x. | ||
|
|
||
| This means that for Airflow 2.x, `trustedProxies: ["*"]` is the only valid configuration. Using | ||
| any other value than `*` will lead the operator to reject reconciliation. | ||
|
|
||
| == Interaction with overrides | ||
|
|
||
| On Airflow 3.x, the operator sets `FORWARDED_ALLOW_IPS` from this field, before `envOverrides` are | ||
| applied -- so an `envOverrides` entry for that variable wins over the value derived from | ||
| `trustedProxies`. This override only takes effect while `trustedProxies` is non-empty: an empty | ||
| list means the api-server is not started with `--proxy-headers` at all, so uvicorn never installs | ||
| the middleware that reads `FORWARDED_ALLOW_IPS`, and the override has no effect regardless of its | ||
| value. | ||
|
|
||
| On Airflow 2.x, the same applies to `AIRFLOW__WEBSERVER__ENABLE_PROXY_FIX` and | ||
| `AIRFLOW__WEBSERVER__PROXY_FIX_X_FOR`. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.