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
Documentation of Phoenix.Endpoint says
:url- configuration for generating URLs throughout the app. Accepts the:host,:scheme,:pathand:portoptions.
So it should be enough to add scheme: "https" to your :url config
Also Liked
dimitarvp
Last Post!
dimitarvp
Popular in Questions
Other popular topics
Latest Phoenix Threads
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #hex
- #security









