Endpoint config with AWS Application Load Balancer

I’m configuring a Phoenix app behind an AWS Application Load Balancer (ALB). The ALB is doing SSL termination. The Phoenix app is HTTP. If my DNS is : https://my.coolapp.com then how do I configure the Phoenix Endpoint in this case?

config :cool_app, CoolAppWeb.Endpoint,
  http: [port: 80],
  url: [host: "https://my.coolapp.com", scheme: "http"]

Something like that? Also, do I put “https://my.coolapp.com” into a check_origin on my UserSocket to allow web sockets to work properly?

Client Browser 443 -> ALB -> ALB terminates the certification -> forward traffic to server on port 80 http

What I outlined above works fine. I did add the https url to the UserSocket check_orgin.

updates to prod.exs

config :autopsy, CoolAppWeb.Endpoint,
  http: [port: 80],
  url: [host: "https://my.coolapp.com", scheme: "http"],
  cache_static_manifest: "priv/static/cache_manifest.json",
  server: true,
  root: ".",
  version: Mix.Project.config()[:version]

updates to user_socket.ex

  transport(
    :websocket,
    Phoenix.Transports.WebSocket,
    check_origin: [
      "http://localhost:4000",
      "http://0.0.0.0:4000",
      "https://my.coolapp.com"
    ]
  )
2 Likes