https://prefect.io logo
r

Romain Vincent

06/27/2023, 8:52 AM
Hello, I recently tried to move my current setup (Server + Worker) from EC2 to a fully self managed ECS cluster elaborating on a Terraform template provided here. The goal here is to hide the server behind a load balancer. However, I have a hard time figuring out how to configure the server so that the UI remain accessible. I pretty much tried all combinations of the following environments variables in my ECS task definition :
Copy code
command = ["prefect", "server", "start", "--host", "0.0.0.0"]
      environment = [
        {
          name = "PREFECT_UI_API_URL",
          value = "http://${aws_lb.prefect_ecs_alb[0].dns_name}:4200/api"
          #value = "<http://0.0.0.0:4200/api>"
        },
        {
          name = "PREFECT_API_URL",
          value = "http://${aws_lb.prefect_ecs_alb[0].dns_name}:4200/api"
          #value = "<http://0.0.0.0:4200/api>"
        },
        {
          name = "PREFECT_SERVER_API_HOST",
          value = "${aws_lb.prefect_ecs_alb[0].dns_name}",
          #value = "0.0.0.0"
        },
        {
          name = "PREFECT_UI_URL",
          value = "http://${aws_lb.prefect_ecs_alb[0].dns_name}:4200"
          #value = "<http://0.0.0.0:4200>"
        }
      ],
I keep getting
Can't connect to server api
errors or a black screen. It seems I can reach the server from my local development machine though. Is there any ressource available for this kind of issue?
Ok so when setting
PREFECT_UI_API_URL
as the LB dns, we had a few small JS errors popping in the background of the UI while the API was still reachable. After some research, I seemed that these were related to SSL encryption. So we set up an actual domain name for our server and associated an SSL certificate to our LB. Then we set
PREFECT_UI_API_URL
as the https url pointing to that domain and it worked. So either prefect could not resolve the LB dns name or Prefect required HTTPS to work properly, but in the end it worked!