vrod

vrod

Multiple HTTPS sites on Gigalixir using master_proxy

I made a post before 1 Gigalixir instance hosting multiple HTTPS sites - #5 by axelson
but I am still not understanding how can I support https. The multi_proxy config was a little bit difficult, but I think as long as your endpoints do not specify a port and they let multi_proxy define the port, it works. But if you have https, I do not see what options are needed (or maybe, it isn’t needed?)

config :master_proxy,
  http: [port: 80],
  #  http: [port: String.to_integer(System.get_env("PORT", "4000"))],  # <--- is this better?
  #  https: [:inet6, port: 443],   # <--- this causes an error.  How to specify a local cert?
  backends: [
    %{
      host: ~r{^(www\.)?myapp\.com$},
      phoenix_endpoint: MyAppWeb.Endpoint
    },
  ]

If https is uncommented, it gets this error:

(ArgumentError) could not start Cowboy2 adapter, missing option :key/:keyfile

but I do not understand how to fix this in dev.

Also I do not understand whether master_proxy should be listening on port 4000 (the PORT), or if it should be listening on port 80.

Thank you sorry I am confused

Marked As Solved

hubertlepicki

hubertlepicki

I think the way Gigalixir works (and also Heroku, Render.com etc) is that they provide you the SSL layer for you, and in your own application you should only be concerned with HTTP layer, and maybe a redirect from HTTP to HTTPS.

So you set up your application the usual way, with listening only over HTTP on $PORT, then add custom domains in Gigalixir and set up redirect - all without changing anything in your code, but rather by altering the Gigalixir configuration with it’s CLI:

Where Next?

Popular in Questions Top

jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set? Thanks.
New
hariharasudhan94
lets say i have a sample like a = 20; b = 10; if (a &gt; b) do {:ok, "a"} end if (a &lt; b) do {:ok, b} end if (a == b) do {:ok, "equa...
New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New

Other popular topics Top

JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set? Thanks.
New
dogweather
I wrote this comment on r/haskell, and it’s not popular there. :wink: But I think I’m on to something… Haskell reminds me of Java, and e...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID&lt;0.412.0&gt; terminating ** (Postgrex.Error) FATAL...
New
AstonJ
Posting this to see if we can make things easier for people to get into Neovim. If you use Neovim and have a favourite distro please let ...
New

We're in Beta

About us Mission Statement