Skip to content

Commit 72e60a8

Browse files
arjav1528choo121600
authored andcommitted
Fix Keycloak provider redirect_uri to use HTTPS behind reverse proxy (apache#61095)
* docs: Enhance Airflow API server configuration in values.yaml * docs: Update Airflow API server args description to include reverse proxy support and provide usage example * docs: Update API server env vars description to include reverse proxy configuration and provide example usage * docs: Add Helm chart configuration details for running Airflow behind a reverse proxy
1 parent 5529b5a commit 72e60a8

3 files changed

Lines changed: 68 additions & 2 deletions

File tree

airflow-core/docs/howto/run-behind-proxy.rst

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,50 @@ To do so, you need to set the following setting in your ``airflow.cfg``::
6666
- Please make sure your proxy does not enforce http-only status on the Set-Cookie headers.
6767
Airflow frontend needs to access the cookies through javascript, and a http-only flag would disturb this functionality.
6868

69+
Helm Chart Configuration
70+
------------------------
71+
72+
When deploying Airflow using the Helm chart behind a reverse proxy (e.g., nginx ingress), you need to configure the API server to respect proxy headers.
73+
74+
Configure the API server arguments to include the ``--proxy-headers`` flag::
75+
76+
apiServer:
77+
args: ["bash", "-c", "exec airflow api-server --proxy-headers"]
78+
79+
If your proxy server is not on the same host as Airflow, set the ``FORWARDED_ALLOW_IPS`` environment variable::
80+
81+
apiServer:
82+
args: ["bash", "-c", "exec airflow api-server --proxy-headers"]
83+
env:
84+
- name: FORWARDED_ALLOW_IPS
85+
value: "*" # Use "*" for trusted environments, or specify proxy IP ranges for production
86+
87+
Additionally, configure your ingress annotations to pass the necessary headers. For nginx ingress, add these annotations::
88+
89+
ingress:
90+
apiServer:
91+
enabled: true
92+
annotations:
93+
nginx.ingress.kubernetes.io/proxy-http-version: "1.1"
94+
nginx.ingress.kubernetes.io/proxy-redirect-off: "true"
95+
nginx.ingress.kubernetes.io/configuration-snippet: |
96+
proxy_set_header Host $http_host;
97+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
98+
proxy_set_header X-Forwarded-Proto $scheme;
99+
proxy_set_header Upgrade $http_upgrade;
100+
proxy_set_header Connection $connection_upgrade;
101+
hosts:
102+
- name: airflow.example.com
103+
tls:
104+
enabled: true
105+
secretName: airflow-tls
106+
107+
Make sure to also set the ``base_url`` in your Airflow configuration::
108+
109+
config:
110+
api:
111+
base_url: https://airflow.example.com
112+
69113
.. spelling::
70114

71115
Uvicorn

chart/values.schema.json

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5821,7 +5821,7 @@
58215821
"default": null
58225822
},
58235823
"args": {
5824-
"description": "Args to use when running the Airflow API server (templated).",
5824+
"description": "Args to use when running the Airflow API server (templated). When running behind a reverse proxy, add `--proxy-headers` to enable Uvicorn to respect X-Forwarded-Proto, X-Forwarded-For, and X-Forwarded-Port headers.",
58255825
"type": [
58265826
"array",
58275827
"null"
@@ -5833,6 +5833,13 @@
58335833
"bash",
58345834
"-c",
58355835
"exec airflow api-server"
5836+
],
5837+
"examples": [
5838+
[
5839+
"bash",
5840+
"-c",
5841+
"exec airflow api-server --proxy-headers"
5842+
]
58365843
]
58375844
},
58385845
"strategy": {
@@ -6351,9 +6358,17 @@
63516358
}
63526359
},
63536360
"env": {
6354-
"description": "Add additional env vars to API server.",
6361+
"description": "Add additional env vars to API server. When running behind a reverse proxy, set `FORWARDED_ALLOW_IPS` to specify which IPs are trusted to send X-Forwarded-* headers. Use `\"*\"` for trusted environments, or specify proxy IP ranges for production.",
63556362
"type": "array",
63566363
"default": [],
6364+
"examples": [
6365+
[
6366+
{
6367+
"name": "FORWARDED_ALLOW_IPS",
6368+
"value": "*"
6369+
}
6370+
]
6371+
],
63576372
"items": {
63586373
"type": "object",
63596374
"properties": {

chart/values.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1617,8 +1617,15 @@ apiServer:
16171617
# Command to use when running the Airflow API server (templated).
16181618
command: ~
16191619
# Args to use when running the Airflow API server (templated).
1620+
# Example: To enable proxy headers support when running behind a reverse proxy:
1621+
# args: ["bash", "-c", "exec airflow api-server --proxy-headers"]
16201622
args: ["bash", "-c", "exec airflow api-server"]
16211623
allowPodLogReading: true
1624+
# Environment variables for the Airflow API server.
1625+
# Example: To configure FORWARDED_ALLOW_IPS when running behind a reverse proxy:
1626+
# env:
1627+
# - name: FORWARDED_ALLOW_IPS
1628+
# value: "*" # Use "*" for trusted environments, or specify proxy IP ranges for production
16221629
env: []
16231630

16241631
# Allow Horizontal Pod Autoscaler (HPA) configuration for apiServer. (optional)

0 commit comments

Comments
 (0)