Skip to content

Honor FORWARDED_ALLOW_IPS when the API server runs under gunicorn - #71429

Merged
pierrejeambrun merged 4 commits into
apache:mainfrom
rjgoyln:proxy-headers-forwarded-allow-ips
Aug 17, 2026
Merged

pierrejeambrun merged 4 commits into
apache:mainfrom
rjgoyln:proxy-headers-forwarded-allow-ips

Conversation

@rjgoyln

@rjgoyln rjgoyln commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Running behind a TLS-terminating proxy is documented as --proxy-headers plus FORWARDED_ALLOW_IPS to name which proxies may be trusted, and server_type = uvicorn works that way. server_type = gunicorn pinned the trust list to "*", so an operator who narrowed it to their own proxy silently got a server accepting X-Forwarded-* from anyone able to reach it directly — including the X-Forwarded-Proto that decides whether session cookies carry the Secure attribute. Gunicorn reads the variable natively, so honouring it is a matter of not overriding it.

Where it is unset the wide default stays and only warns, since off-host proxies depend on it; tightening waits for Airflow 4. Turning --proxy-headers off now trusts nobody, which is what the flag already meant under uvicorn.

Note on #47878

The audit there closes with "For uvicorn, ther's no forwarded_allow_ips which is probably a gap". Read the other way round, uvicorn already matches run-behind-proxy.rst and the hardcoded "*" is the anomaly. Every cookie site that audit lists now uses the proxy-aware secure = ... expression, leaving this as the last behavioural item on the issue.

related: #47878


Was generative AI tooling used to co-author this PR?
  • Yes — Claude Code (Opus 5)

Generated-by: Claude Code (Opus 5) following the guidelines

Running behind a TLS-terminating proxy is documented as `--proxy-headers`
plus `FORWARDED_ALLOW_IPS` to say which proxies may be trusted, and that is
what the uvicorn server type does. The gunicorn server type forced the
trust list to every address instead, so an operator who narrowed it to
their proxy silently got a server that accepted X-Forwarded-* from anyone
able to reach it directly -- including the X-Forwarded-Proto that decides
whether session cookies are issued with the Secure attribute.

Both server types now follow the documented contract.

related: apache#47878
@rjgoyln
rjgoyln force-pushed the proxy-headers-forwarded-allow-ips branch from fa59e9b to 4efba80 Compare August 11, 2026 11:56

@pierrejeambrun pierrejeambrun left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR just one adjustment to make I believe.

…ng it

Deployments whose proxy is not on the API server's host, and which never set
FORWARDED_ALLOW_IPS, are relying on gunicorn being handed a trust list of
every address. Reading the variable where it is set already gives operators
back the control they thought they had; taking the wide default away from
everyone else belongs in a major version.

The reverse-proxy guide named uvicorn throughout, from when it was the only
option.
@rjgoyln

rjgoyln commented Aug 12, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the PR just one adjustment to make I believe.

Hi @pierrejeambrun,

Thanks for the great suggestions! Really appreciate it.
I agree with the backward compatibility concern. I've updated the PR accordingly:

  • Gunicorn & Compat: Implemented the fallback to "*" with a RemovedInAirflow4Warning to ensure existing deployments won't break.
  • Docs: Replaced mentions of "Uvicorn" with the generic "application server" and added the clarification about supported servers.
  • Tests: Updated the parameterized tests to cover the new deprecation warning logic.

I also removed the "Behavior change" section from the PR description.

@pierrejeambrun
pierrejeambrun merged commit d4581ae into apache:main Aug 17, 2026
84 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

Backport successfully created: v3-3-test

Note: As of Merging PRs targeted for Airflow 3.X
the committer who merges the PR is responsible for backporting the PRs that are bug fixes (generally speaking) to the maintenance branches.

In matter of doubt please ask in #release-management Slack channel.

Status Branch Result
✅ v3-3-test PR Link

aws-airflow-bot pushed a commit to aws-mwaa/upstream-to-airflow that referenced this pull request Aug 17, 2026
…gunicorn (apache#71429)

* Honor FORWARDED_ALLOW_IPS when the API server runs under gunicorn

Running behind a TLS-terminating proxy is documented as `--proxy-headers`
plus `FORWARDED_ALLOW_IPS` to say which proxies may be trusted, and that is
what the uvicorn server type does. The gunicorn server type forced the
trust list to every address instead, so an operator who narrowed it to
their proxy silently got a server that accepted X-Forwarded-* from anyone
able to reach it directly -- including the X-Forwarded-Proto that decides
whether session cookies are issued with the Secure attribute.

Both server types now follow the documented contract.

related: apache#47878

* Delete airflow-core/newsfragments/71429.significant.rst

* Warn about the wide gunicorn proxy-header default instead of tightening it

Deployments whose proxy is not on the API server's host, and which never set
FORWARDED_ALLOW_IPS, are relying on gunicorn being handed a trust list of
every address. Reading the variable where it is set already gives operators
back the control they thought they had; taking the wide default away from
everyone else belongs in a major version.

The reverse-proxy guide named uvicorn throughout, from when it was the only
option.

* Re-run CI after a transient go-mod-tidy download failure
(cherry picked from commit d4581ae)

Co-authored-by: rjgoyln <[email protected]>
potiuk pushed a commit that referenced this pull request Aug 17, 2026
…gunicorn (#71429)

* Honor FORWARDED_ALLOW_IPS when the API server runs under gunicorn

Running behind a TLS-terminating proxy is documented as `--proxy-headers`
plus `FORWARDED_ALLOW_IPS` to say which proxies may be trusted, and that is
what the uvicorn server type does. The gunicorn server type forced the
trust list to every address instead, so an operator who narrowed it to
their proxy silently got a server that accepted X-Forwarded-* from anyone
able to reach it directly -- including the X-Forwarded-Proto that decides
whether session cookies are issued with the Secure attribute.

Both server types now follow the documented contract.

related: #47878

* Delete airflow-core/newsfragments/71429.significant.rst

* Warn about the wide gunicorn proxy-header default instead of tightening it

Deployments whose proxy is not on the API server's host, and which never set
FORWARDED_ALLOW_IPS, are relying on gunicorn being handed a trust list of
every address. Reading the variable where it is set already gives operators
back the control they thought they had; taking the wide default away from
everyone else belongs in a major version.

The reverse-proxy guide named uvicorn throughout, from when it was the only
option.

* Re-run CI after a transient go-mod-tidy download failure
(cherry picked from commit d4581ae)

Co-authored-by: rjgoyln <[email protected]>
potiuk pushed a commit that referenced this pull request Aug 17, 2026
…gunicorn (#71429) (#71708)

* Honor FORWARDED_ALLOW_IPS when the API server runs under gunicorn

Running behind a TLS-terminating proxy is documented as `--proxy-headers`
plus `FORWARDED_ALLOW_IPS` to say which proxies may be trusted, and that is
what the uvicorn server type does. The gunicorn server type forced the
trust list to every address instead, so an operator who narrowed it to
their proxy silently got a server that accepted X-Forwarded-* from anyone
able to reach it directly -- including the X-Forwarded-Proto that decides
whether session cookies are issued with the Secure attribute.

Both server types now follow the documented contract.

related: #47878

* Delete airflow-core/newsfragments/71429.significant.rst

* Warn about the wide gunicorn proxy-header default instead of tightening it

Deployments whose proxy is not on the API server's host, and which never set
FORWARDED_ALLOW_IPS, are relying on gunicorn being handed a trust list of
every address. Reading the variable where it is set already gives operators
back the control they thought they had; taking the wide default away from
everyone else belongs in a major version.

The reverse-proxy guide named uvicorn throughout, from when it was the only
option.

* Re-run CI after a transient go-mod-tidy download failure
(cherry picked from commit d4581ae)

Co-authored-by: rjgoyln <[email protected]>
vatsrahul1001 pushed a commit that referenced this pull request Sep 7, 2026
…gunicorn (#71429) (#71708)

* Honor FORWARDED_ALLOW_IPS when the API server runs under gunicorn

Running behind a TLS-terminating proxy is documented as `--proxy-headers`
plus `FORWARDED_ALLOW_IPS` to say which proxies may be trusted, and that is
what the uvicorn server type does. The gunicorn server type forced the
trust list to every address instead, so an operator who narrowed it to
their proxy silently got a server that accepted X-Forwarded-* from anyone
able to reach it directly -- including the X-Forwarded-Proto that decides
whether session cookies are issued with the Secure attribute.

Both server types now follow the documented contract.

related: #47878

* Delete airflow-core/newsfragments/71429.significant.rst

* Warn about the wide gunicorn proxy-header default instead of tightening it

Deployments whose proxy is not on the API server's host, and which never set
FORWARDED_ALLOW_IPS, are relying on gunicorn being handed a trust list of
every address. Reading the variable where it is set already gives operators
back the control they thought they had; taking the wide default away from
everyone else belongs in a major version.

The reverse-proxy guide named uvicorn throughout, from when it was the only
option.

* Re-run CI after a transient go-mod-tidy download failure
(cherry picked from commit d4581ae)

Co-authored-by: rjgoyln <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants