SSL for Custom Domains: Phoenix

Our config looks like this, prod.exs:

config :fly, FlyWeb.Endpoint,
  url: [host: "example.com", port: 80],
  cache_static_manifest: "priv/static/cache_manifest.json",
  force_ssl: [
    host: nil,
    rewrite_on: [:x_forwarded_port, :x_forwarded_proto],
    hsts: false, # maybe true when we use this for real
  ]

And in runtime.exs:

  config :fly, FlyWeb.Endpoint,
    server: true,
    url: [host: "fly.io"],

This seems to work fine! I don’t know if it’s the best possible way to do it, but it did require us putting a single url.host value in the endpoint config.

1 Like