https://prefect.io logo
Title
h

Hans Lellelid

01/24/2023, 1:34 PM
Hey folks -- I feel like I've missed something obvious, but how do I configure Prefect 2.x to run successfully behind a reverse proxy? I see references to
PREFECT_SERVER__BASE_URL
but that seems to be for v1. I'm using Traefik to reverse proxy https traffic to Prefect. The UI loads, but I see this error displayed: "Can't connect to Orion API at http://0.0.0.0:4200/api"
root@e6695489d725:/opt/app/prefect# prefect config view
PREFECT_PROFILE='default'
PREFECT_ORION_API_HOST='0.0.0.0' (from env)
PREFECT_ORION_DATABASE_CONNECTION_URL='********' (from env)
My interpretation was that specifying
0.0.0.0
for the PREFECT_ORION_API_HOST was instructing Prefect to listen on non-localhost, but maybe that was a misunderstanding.
Ok, answering my own question ... it seems that the
PREFECT_API_URL
needs to also be set for the server when the server is running behind a reverse proxy. Here was my fix:
$ nomad alloc exec -i -t -task prefect-server 58c8ec49 /bin/bash
root@11499a2af292:/opt/app/prefect# prefect config view
PREFECT_PROFILE='default'
PREFECT_API_URL='<https://prefect-orion-dev.mycompany.tld/api>' (from env)
PREFECT_ORION_API_HOST='0.0.0.0' (from env)
PREFECT_ORION_DATABASE_CONNECTION_URL='********' (from env)
I created a pull request to suggest an improvement to the docs.
n

Nate

01/24/2023, 2:39 PM
Thanks for the PR! glad you got it figured out
:gratitude-thank-you: 1