https://prefect.io logo
#prefect-community
Title
# prefect-community
b

Bogdan Serban

10/04/2022, 10:05 AM
Hello everyone! I am trying to deploy prefect orion server behind an nginx reverse proxy, at a different location than
/
, for instance
/prefect/
. I am having an issue with loading the UI when I access
<http://localhost/prefect/>
as the UI cannot load the corresponding assets, because it ignores the location prefix when doing the requests, for instance:
<http://localhost/assets/index.1a4d60fb.js>
is available at
<http://localhost/prefect/assets/index.1a4d60fb.js>
. Is there a way to specify a prefix or some sort of redirect URL for the UI to use when doing requests?
t

Thomas Fredriksen

10/04/2022, 10:17 AM
Have you tried setting
PREFECT_ORION_UI_API_URL
to
<http://localhost/prefect/api>
?
b

Bogdan Serban

10/04/2022, 10:20 AM
Yes, I did that, but the issue is with the static files which the Prefect UI is loading.
t

Thomas Fredriksen

10/04/2022, 10:25 AM
We have done something similar with Traefik in that past. The solution was to add a path-stripping middleware. I have never done this with NGINX, but maybe this helps? https://serverfault.com/a/562850
b

Bogdan Serban

10/04/2022, 10:27 AM
Thanks for the tip. I have tried that already and I have managed to load the UI, but whenever I am navigating to a new route in the UI, for instance to
/runs
, starting from
localhost/prefect/
I am redirected to l
localhost/runs
, instead of
localhost/prefect/runs
t

Timo

10/24/2022, 11:23 AM
@Thomas Fredriksen I try to manage this in Traefik as well but can get it to setup. Can you point me into the direction to setup the middleware?
t

Thomas Fredriksen

10/24/2022, 12:13 PM
@Timo - We are using the External Auth Server (https://github.com/travisghansen/external-auth-server) as a middleware. Once set up, it is just a matter of specifying the middleware CRD:
Copy code
apiVersion: <http://traefik.containo.us/v1alpha1|traefik.containo.us/v1alpha1>
kind: Middleware
metadata:
  name: eas-prefect
  namespace: prefect
spec:
  forwardAuth:
    address: >-
      <https://external-auth-server.myhost.com/verify?fallback_plugin=0&config_token=CONFIG_TOKEN>
    authResponseHeaders:
      - X-Forwarded-User
      - X-Forwarded-Uri
      - X-Userinfo
      - X-Id-Token
      - X-Access-Token
      - Authorization
    trustForwardHeader: true
🙌 1
t

Timo

10/24/2022, 12:56 PM
@Thomas Fredriksen thanks for sharing this. I'll looking into that. This means that you don't use path-stripping middleware anymore, right?
t

Thomas Fredriksen

10/24/2022, 5:26 PM
You will need the path-stripping middleware if your path is not root. For example if you are hosting prefect at
<http://myhost.com/path/to/prefect|myhost.com/path/to/prefect>
, then you will need to apply path stripping to
/path/to/prefect
t

Timo

10/25/2022, 7:11 AM
I receive the error in console for the static files. There is the
/prefect
path missing... But configured the middleware as traefik label as following:
Copy code
labels:
      - "traefik.enable=true"
      - "traefik.http.routers.prefectserver.rule=(Host(`bla.bla`) && PathPrefix(`/prefect`))"
      - "traefik.http.middlewares.prefect-prefix.stripprefix.prefixes=/prefect"
      - "traefik.http.middlewares.prefect-prefix.stripprefix.forceSlash=false"
      - "traefik.http.routers.prefectserver.middlewares=prefect-prefix@docker"
t

Thomas Fredriksen

10/27/2022, 8:21 AM
@Timo I'm afraid I have not seen this issue before. Have you gotten it to work without the
/prefect
-path?
t

Timo

10/27/2022, 1:20 PM
@Thomas Fredriksen thanks, for your response. Without the
/prefect
path it works like a charm. But if I add the prefix and the stripping it doesn't get added to the static files somehow...
t

Thomas Fredriksen

10/28/2022, 11:56 AM
@Timo The issue may be related to how the API-calls from the Web-UI are handled. One thing you could try is to set a rule based on the request referer. Something like
Host("<http://myhost.com|myhost.com>") && Headers("referer", "<http://myhost.com/prefect|myhost.com/prefect>")
t

Timo

10/28/2022, 2:22 PM
@Thomas Fredriksen do you mean something like `- "traefik.http.routers.prefectserver.rule=Host(
<http://myhost.com|myhost.com>
) && Headers(
referer
,
<http://myhost.com/prefect|myhost.com/prefect>
)"` This ends up in a 404 😞
t

Thomas Fredriksen

10/28/2022, 3:54 PM
@Timo It could be worth trying with
origin
instead of
referer
. Also - is your
PREFECT_ORION_UI_API_URL
environment variable set correctly?
t

Timo

11/01/2022, 8:37 AM
@Thomas Fredriksen this ends in a 404, too 😞 My
PREFECT_ORION_UI_API_URL
is set to "http://myhost.com/prefect". But even if I use "http://localhost/prefect/api" as suggested by you in another post it doesn't work. If I use the pathprefix I can connect through CLI the only problem is, that I can't load the assets in the browser....
d

Dylan McReynolds

11/04/2022, 10:14 PM
Been looking at this same issue. The UI uses an environment variable called ORION_SERVE_BASE, but this has to be set a build time, as I see in the Dockerfile: https://github.com/PrefectHQ/prefect/blob/c5a14cef4ead7d6c7e550194d4bbb7f3b90f15f3/Dockerfile#L35 So I think you’d need to build the UI yourself with this environment variable set.
t

Timo

11/28/2022, 2:22 PM
@Dylan McReynolds did you solve this issue? I tried to build the image on my own but didn't work sofar without modification bc ORION_SERVE_BASE is not a build arg. So further modifications are necessary. Even when setting ORION_SERVE_BASE this doesn't work for me...
4 Views