Example Repo: Adding dynamic custom domains as a feature to a Phoenix app

Hey folks, I’ve created an example repo that I’ve made to show how you could add dynamic custom domains to a Phoenix app. I couldn’t find many resources on this out there, so I hope this helps! I’ll turn this into a guide as well some time soon.

Link to the repo

What do I mean by dynamic custom domains?
Letting you or your end users connect multiple domains (i.e. something.com is a domain) to your app at runtime, and likely returning data/content/responses specific to that custom domain.


  • A blog hosting platform allowing users to connect their own domain to only their blog
  • An ecommerce platform allowing users to connect their own domain to their store

What does the example repo do?

  • It’s a pretty standard Phoenix 1.7 app
  • The example purpose being a blog host that lets you connect a custom domain to a blog.
  • When you visit the custom domain, it should load only that blog and it’s posts.
  • Otherwise, if you go to the primary domain of the app, it should load up the interface to manage blogs/posts.
  • It uses liveview, to show how to handle websockets as well as http requests for custom domains.

I get a 404?

Ah yes, probably helps to make the repo public :man_facepalming:
Should work now!

I also wanted to add, if anyone has any questions, finds a bug, or has suggestions, please feel free to post them here or in the repo issues! I’d love to make it better for people who might find this down the line.