Hello everyone! I am trying to deploy prefect orio...
# prefect-community
b
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
Have you tried setting
PREFECT_ORION_UI_API_URL
to
<http://localhost/prefect/api>
?
b
Yes, I did that, but the issue is with the static files which the Prefect UI is loading.
t
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
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
@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
@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
@Thomas Fredriksen thanks for sharing this. I'll looking into that. This means that you don't use path-stripping middleware anymore, right?
t
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
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
@Timo I'm afraid I have not seen this issue before. Have you gotten it to work without the
/prefect
-path?
t
@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
@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
@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
@Timo It could be worth trying with
origin
instead of
referer
. Also - is your
PREFECT_ORION_UI_API_URL
environment variable set correctly?
t
@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
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
@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...