vfsoraki

vfsoraki

Phoenix generate https urls

I have a Phoenix 1.3 app that is running behind an Nginx reverse proxy, all in HTTP.

I wanted to migrate to HTTPS, so I got a certificate from Let’s Encrypt and changed Nginx config to do it. All worked fine.

I generate a bunch of urls inside my Phoenix app, using MyApp.Web.Router.Helpers.*, but they generate HTTP urls. So I channged my app config in prod.exs from url: [host: "my.host", port: 80] to url: [host: "my.host", port: 443]. But now the urls are being generated like http://my.host:443/path.

How can I tell Phoenix to stay on HTTP, but generate urls in HTTPS?

PS. If I was not clear, I don’t want my Nginx and Phoenix to talk over HTTPS, I just want Phoenix url helpers to generate HTTPS urls. I have already read Endpoint configuration, but I could not find something useful.

Marked As Solved

NobbZ

NobbZ

Documentation of Phoenix.Endpoint says

:url - configuration for generating URLs throughout the app. Accepts the :host, :scheme, :path and :port options.

So it should be enough to add scheme: "https" to your :url config

Also Liked

dimitarvp

dimitarvp

It’s scheme btw. Caught me off-guard for a sec so figured I should warn future readers.

Last Post!

dimitarvp

dimitarvp

As far as I can tell, it’s already edited to show scheme and not schema.

Where Next?

Popular in Questions Top

vegabook
I’m brand new to Phoenix and I have stripped one of the demo applications to the bone. I just want to get an svg up on the screen. Here i...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? Ecto.Repo — Ecto v3.14.0 has exampl...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New

Other popular topics Top

vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
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 54006 488
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
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

Latest on Elixir Forum

Elixir Forum

We're in Beta

About us Mission Statement