How do I configure Phoenix / Cowboy to host two websites at my IP address?


I run a small webserver using Nginx (at them moment) at home, where I have a fixed IP address. I know Nginx and Apache can be configured to run two different websites, with different domain names, on the same IP address, but can the same be done with Phoenix / Cowboy? It would have to be a solution that is robust to channels being used. How do I go about doing this?

It is a good practice to run your app servers behind nginx, using nginx as a reverse proxy/load balancer.

That way you can run multiple apps on the same IP.


Hi @vegabook,

Yes this thing could be done using phoenix and cowboy.
We can configure the plug to send requests to difference endpoints (one domain per endpoint). It will functions like apache or nginx reverse proxy different domains to difference web apps.

I think I have saw this one working project like this before, I will try to find a it’s source and put here as the example. (that project is setup inside umbrella app. It’s has 3 apps inside -

  1. Plug and Cowboy
  2. Phoenix app
  3. another Phoenix app). It works like this when a requests come in the first app (plug and cowboy) will see read the request domain and then will forward to one of the other phoenix apps upon the domain addresss.


1 Like