Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

https urls in coherence emails when phoenix is behind a proxy

I have my phoenix app set up behind nginx. Nginx is serving https traffic.

I want emails from coherence to contain https urls like https://my_domain.com/..., but I can't figure out how to do so.

Here is my app's config:

config :my_app, MyApp.Endpoint,
  http: [port: 8080],
  url: [host: "my_domain.com", port: 443],
  # ...

With this config, urls in emails are like this: my_domain.com:443/some_path. And when I remove port: 443, they became my_domain.com:8080/some_path. And adding force_ssl: [hsts: true] doesn't help too.

Of cource I could set url: [host: "my_domain.com", port: 80] and set nginx to redirect all http requests to port 443, but it seems wrong to me. I could edit email templates to force https urls, but this also seems wrong.

Or maybe using a proxy in front of an erlang app is not an erlang way and I just didn't get it yet?

like image 607
Vizvamitra Avatar asked Mar 04 '26 16:03

Vizvamitra


1 Answers

You need to set scheme to "https". This should work:

config :my_app, MyApp.Endpoint,
  http: [port: 8080],
  url: [host: "my_domain.com", port: 443, scheme: "https"],
  # ...
like image 142
Dogbert Avatar answered Mar 07 '26 16:03

Dogbert