damien

damien

Hi,

I have set up a VPS, installed certbot and managed to run Phoenix 1.5.7 using HTTPS.
The paths to the key and cert files from lets encrypt are read by phoenix from ENV variables in the prod.secret.exs file.
The files will be renewed automatically by certbot every 3 months using a cron job.

I can’t find answers to the following questions:

  • How to deal with the renewal of the keys on the Phoenix side? Do I have to restart the Phoenix server or will Phoenix read the updated files in due time?

  • Would the situation be the same with the new elixir runtime config files?

I would appreciate any insights on these issues which are new to me.
Thanks in advance for your help.

Showing Posts 1 to 8

crova

crova

While I don’t know the exact answers to your questions, maybe you can find some insights from this library.
And if you would accept bringing a dependency to your app, you could use the library to manage your certificates and eventually ditch certbot.

soup

soup

I keep my certs in /etc/letsencrypt/live/..., set in a docker env file.

I add this to my endpoint:

  plug Plug.Static,
    at: "/",
    from: "certbot/"

and have a matching rel/overlays/certbot folder (it’s empty, just exists to create the folder).

I have this in my phoenix service in my docker compose file:

    volumes:
      - ${LETS_ENCRYPT_ROOT}:/etc/letsencrypt:ro
      - ./certbot:/app/certbot

I use certbot’s webroot option and basically tell it to go use /my/compose/root/certbot, which gets mounted at /app/certbot, which cowboy will serve at /, and it all just works.

First run you have to shuffle some mess around but it’s easier to use certbot’s own webserver to generate the first set of certs, then change it to use webroot.

The SSL guide recommends you use the fullchain.pem file for atomic updates, you don’t have to restart phx.

sam701

sam701

I use traefik running in front of my app. It cares about the certificate renewal and also routing.

Exadra37

Exadra37

I am also using it for now, but be very careful with trusting in the headers because they don’t cleanup the headers as they should. For example, the x-forward-for is set by them, but it can also be set by the client sending the request, thus you end-up with two ips in your backend:

curl -I --header "X-Forwarded-For: 82.22.85.84" https://your-site-behind-traefik.tld

Your backend logs:

app_1        | 18:51:33.229 | info | HEAD / | request_id=FnZrTLGwHk701AMAAAax proxy_ip=82.22.85.84, xx.23x.8x.8x remote_ip=::ffff:172.18.0.2 user_agent=curl/7.68.0 module=Phoenix.Logger function=phoenix_endpoint_start/4 line=178

So which IP you gonna trust now proxy_ip=82.22.85.84, xx.23x.8x.8x?

It seems that the last is the real IP from the client, but Treafik should always drop any header it sets, as any good behaved proxy does :slight_smile:

sam701

sam701

That is true, overwritten headers could be an issue. But maybe it is not an issue for @damien I find it nice not to care about certificate renewal.

Regarding the overwritten headers… what if you configure traefik / your LB to use some other, “unforgeable” name for the header, e.g. X-Forwarded-34535435987-For? :slight_smile:

Exadra37

Exadra37

Could be a workaround if Traefik allows for that, but then you also need to account for that in software that assumes the standard header for the proxy to be the x-fowarded-for.

I was loving Traefik until I discovered this issue and that they kept “refusing” to fix it, despite open bugs.

So, I will have to ditch Traefik in a near future, because if they screw-up in the basics of security and won’t fix I don’t even want to imagine what else they got fundamentally wrong.

Exadra37

Exadra37

I strongly recommend you to use the library mentioned by @crova:

This library is from @sasajuric the author of the book Elixir in Action and also a very reputable member of our community :slight_smile:

sasajuric

sasajuric

Author of Elixir In Action

If those files are updated, I think you don’t need to restart anything and the new certs will be eventually picked up. FWIW site_encrypt forces this manually by invoking :ssl.clear_pem_cache.

— All posts loaded —

Where Next? Top

Trending in Questions Top

axelson
One of my LiveView view’s has a very heavy javascript dependency so I want to avoid loading it for every page on the site, while still us...
New
yasoob
Hi all! I know that quite a few people use Phoenix LiveView but it is hard to get a more up-to-date list of folks/companies using it. I ...
New
Hellowman
Hello everyone! I am new to coding with Elixir/Erlang. And i am looking for some utilities for fuzzing testing like AFL++. Does anyone ...
New
yarrichar
I’m very new to Elixir, so sorry if this is a silly question: I am wondering what happens to the mailbox of a process when the machine i...
New
mandar1045
I load tested a plain Phoenix chat app backed by Postgres with 100 million messages in it, everything on default settings, to see what br...
New
caioaao
Hey, I know this has been discussed ad nauseum, but I couldn’t find a definitive answer or at least some consensus around this, so let me...
New
Liam_or
I don’t suppose you can lazy load a library depending on runtime data? For example if it’s a certain user they can lazy load ‘library A’ ...
New

Other Trending Topics Top

GenericJam
Edit: 2026 May 15 - This post is archived. Mob is alive!! Main docs: mob v0.7.11 — Documentation A bit of explanation for the slightly c...
261 13183 112
New
mudasobwa
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
charlenopires
Hi everyone :waving_hand: I’ve been working on PhiaUI, an open-source UI component library for Phoenix LiveView, and I wanted to share i...
New
PJUllrich
On November 23, 2026, an unauthorized third party exploited a vulnerability in hex.pm (CVE-2026-129514, CVSS 10.0) that let them run comm...
New
akoutmos
@hugobarauna, Dr. Dimitrios Koutmos (my brother) and I (Alex Koutmos) have been hard at work on writing a book on how you can use Elixir ...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews