Gunicorn - HTTP and HTTPS in the same instance?

Skip Montanaro skip.montanaro at gmail.com
Fri Jan 7 13:51:48 EST 2022


Hopefully some Pythonistas are also Gunicornistas. I've had little success
finding help with a small dilemma in the docs or in other more specific
sources.

I'm testing out a new, small website. It is just Gunicorn+Flask. I'd like
to both listen for HTTP and HTTPS connections. Accordingly, in my config, I
have the Gunicorn process bind to both ports 80 and 443 if running as root:

if IAM_ROOT:
    bind = [
        '0.0.0.0:443',
        '0.0.0.0:80',
    ]
else:
    bind = [
        '0.0.0.0:8080',
    ]

Gunicorn listens on both ports, but insists on SSL/TLS chit chat over port
80, not just port 443 (which seems to work okay). Is there some magic
incantation to get it to just talk HTTP on port 80, or will I need to spin
up two instances? (The non-root config works fine - plain old HTTP over
port 8080.)

Thx,

Skip


More information about the Python-list mailing list