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

RisingFromAshes
I’ve read in another post that it may be possible with a router helper - but I couldn’t find an appropriate one, and tbh, I’m still just ...
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
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
komlanvi
Hi everyone, I was playing with phoenix liveView but I run into an issue. I have a form and want to validate each input text when the te...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
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

nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New
JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 54092 488
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
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

We're in Beta

About us Mission Statement