Skip to content

Automatically configure the Gunicorn web server #4

Open

Description

@edmorley

The classic Heroku Python buildpack automatically configures gunicorn at runtime (it sets FORWARDED_ALLOW_IPS and GUNICORN_CMD_ARGS):
https://github.com/heroku/heroku-buildpack-python/blob/main/vendor/python.gunicorn.sh

Something similar to that should be added to the Python CNB for parity with the classic buildpack.

Internal tracking epic

Activity

  1. added
    enhancementNew feature or request
    classic buildpack parityFeatures required for parity with the classic Heroku Python buildpack
    and removed
    enhancementNew feature or request
    on Feb 28, 2023
  2. edmorley commented on Nov 26, 2024

    @edmorley
    MemberAuthor

    Notes:

    • FORWARDED_ALLOW_IPS is used by both gunicorn and uvicorn. Setting it to * is environment-specific (since it requires knowing there is a LB/proxy that's correctly setting headers), and forgetting to set it (eg in the app's own config) can result in confusing behaviour (eg HTTP -> HTTPS redirect loops). Therefore we should continue to do so in the CNB.
    • Setting --access-logfile - in GUNICORN_CMD_ARGS has caused confusion in customer tickets for the classic buildpack (example; since it's not obvious how the access logs are being enabled, or how to override that. Plus the default access log format includes query strings which can in some cases contain tokens/secrets). Given the Heroku router already emits access logs, it feels like adding additional gunicorn-level access logs should be an app concern, and not something the buildpack magically configures. So I think we should drop this for the CNB, and update the Python getting started guide's gunicorn.conf.py to demonstrate enabling access logs (and for bonus points, how to change the format).
  3. self-assigned this
    on Nov 26, 2024
  4. added a commit that references this issue on Dec 8, 2024
  5. edmorley commented on Dec 8, 2024

    @edmorley
    MemberAuthor
    • So I think we should drop this for the CNB, and update the Python getting started guide's gunicorn.conf.py to demonstrate enabling access logs (and for bonus points, how to change the format).

    The getting started guide now configures access logs explicitly (and with an improved log format):
    heroku/python-getting-started#246

  6. added a commit that references this issue on Apr 27, 2025
  7. added a commit that references this issue on Aug 8, 2025
  8. added a commit that references this issue on Sep 26, 2025
  9. added a commit that references this issue on Nov 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

classic buildpack parityFeatures required for parity with the classic Heroku Python buildpack

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions