https://prefect.io logo
k

Kyle

07/09/2023, 3:28 PM
I have an issue with UI. I setup local server on remote box to run at 127.0.0.1:4200. I setup a super simple nginx proxy to route mydomaincom4201 to 127.0.0.1:4200. This doesnt work because your profiles/api are set to an absolute URL and so when i go to the UI all the links are going to 127.0.0.1 and broken. Ok. So I set the prefect url to mydomain.com. UI now works fine. Now when i go to create a new profile from default using cli, it times out because the url is no longer 127.0.0.1 and your cli tool is trying to connect to it. How can I fix this issue?
Copy code
$ prefect profile create wb --from default
$ prefect profile use 'wb'
⠦ Checking API connectivity...
TimeoutError
c

Christopher Boyd

07/09/2023, 4:01 PM
127.0.0.1
is a loopback, the only thing listening on that is the local host
if you want to expose it to another host, you need to expose it on 0.0.0.0
k

Kyle

07/09/2023, 4:03 PM
^ then in the UI the urls would say 0.0.0.0 which would also be broken links?
c

Christopher Boyd

07/09/2023, 4:04 PM
0.0.0.0 is a special address just like the loopback that means listen on all interfaces
k

Kyle

07/09/2023, 4:04 PM
i dont want to expose the UI directly to the internet. the proxy is used for security.
c

Christopher Boyd

07/09/2023, 4:04 PM
if you setup to just listen on localhost via loopback, you’re only going to be access it locally
k

Kyle

07/09/2023, 4:04 PM
this is common practive for decades.
c

Christopher Boyd

07/09/2023, 4:04 PM
the proxy still needs to understand how to route to the backend
if the server is only listening on a loopback
it wont accept connections from the proxy
because it’s not listening for them
k

Kyle

07/09/2023, 4:05 PM
you arent understanding the problem.
i run your service at 127.0.0.1 just like every other service i would run. it listens local. this is not the problem. i dont want to expose your service via 0.0.0.0. i want to use a nginx proxy that routes to 127.0.0.1. the problem is your UI config needs the public url. i can set this and it works fine. the problem is when i create a profile using your cli it timesout out now.
your cli should be looking at 127.0.0.1 not my public domain that the UI is using.
Copy code
$ prefect profile create wb --from default
$ prefect profile use 'wb'
⠦ Checking API connectivity...
TimeoutError
^ this is the problem not the proxy
c

Christopher Boyd

07/09/2023, 4:11 PM
and you already set the
PREFECT_UI_API_URL
?
Copy code
When using a reverse proxy (such as Nginx or Traefik) to proxy traffic to a locally-hosted Prefect UI instance, the Prefect server also needs to be configured to know how to connect to the API. The PREFECT_UI_API_URL should be set to the external proxy URL (e.g. if your external URL is <https://prefect-server.example.com/> then set PREFECT_UI_API_URL=<https://prefect-server.example.com/api> for the Prefect server process). You can also accomplish this by setting PREFECT_API_URL to the API URL, as this setting is used as a fallback if PREFECT_UI_API_URL is not set.
k

Kyle

07/09/2023, 4:11 PM
i get timeout error from your cli cloning the profile because PREFECT_UI_API_URL is set to the public url. your cli should be using 127.0.0.1
i read that… should PREFECT_UI_API_URL be mydomain.com and PREFECT_API_URL be 127.0.0.1 ? would that solve it?
c

Christopher Boyd

07/09/2023, 4:13 PM
I still don’t really understand your issue - are you trying to run the CLI local on the same server that is hosting?
k

Kyle

07/09/2023, 4:13 PM
there needs to be a distinction between the UI api url and the cli api url. in the nginx case they are not the same.
c

Christopher Boyd

07/09/2023, 4:13 PM
or are you trying to run the CLI somehwere else, and point to that host?
k

Kyle

07/09/2023, 4:14 PM
super simple setup. local service on a remote single linux box. not kubernetes or ecs or anything fancy. simple UI with nginx proxy. flows run locally. as simple as it gets.
Copy code
there needs to be a distinction between the UI api url and the cli api url. in the nginx case they are not the same.
c

Christopher Boyd

07/09/2023, 4:15 PM
That’s not what I mean - where are you trying to create a profile
k

Kyle

07/09/2023, 4:16 PM
via SSH on the server. nothing is local on my machine.
Copy code
$ prefect profile create wb --from default
$ prefect profile use 'wb'
⠦ Checking API connectivity...
TimeoutError
the default had mydomain set for PREFECT_UI_API_URL
so when i cloned it, it timedout. it should be talking to 127.0.0.1 not mydomain.
mydomain is for the UI in the browser. not the cli via SSH console.
c

Christopher Boyd

07/09/2023, 4:18 PM
Are you unable to create a fresh profile at all and set it to what it should be?
k

Kyle

07/09/2023, 4:18 PM
Copy code
⠦ Checking API connectivity...
TimeoutError
why do i get this?
c

Christopher Boyd

07/09/2023, 4:18 PM
because it can’t reach the API
k

Kyle

07/09/2023, 4:18 PM
exactly.
c

Christopher Boyd

07/09/2023, 4:19 PM
prefect profiles are local
k

Kyle

07/09/2023, 4:19 PM
exactly.
c

Christopher Boyd

07/09/2023, 4:20 PM
I don’t understand your issue then - if you have a profile set on the host, and it can’t talk to the API that is being served locally because the value is not correct, then I’m not sure what else to help with other than setting the UI and API urls properly
the fact that it’s a remote host, or behind a proxy is kind of irrelevant to a prefect profile being set on the same system running the server
k

Kyle

07/09/2023, 4:20 PM
if i change the setting to 127.0.0.1 then the nginx proxy dont work.
Copy code
there needs to be a distinction between the UI api url and the cli api url. in the nginx case they are not the same.
j

Joe Harrison

08/17/2023, 11:22 PM
@Kyle was there a conclusion to this? Did you get the proxy to work without breaking the cli or vice-versa?
k

Kyle

08/18/2023, 2:34 PM
nope. i went on to work on other stuff but im assuming this might still be an issue when i move to production or do more then just one off test flowruns
3 Views