Certbot and nginx - renewal and setup without service downtime
2 min read

Certbot and nginx - renewal and setup without service downtime

227 words

When installing/renewing let’s encrypt on a web server with nginx, we have to decide whether to do it with a temporary server, which means we must temporarily stop the web service, or indicate what the DocumentRoot of the web server is for the domain.

The latter implies that the website or service has a “public” DocumentRoot, and that’s not always easy when we’re using, for example, a Python, Java, or Go application and nginx as a proxy.

To be able to create or renew the certificate without stopping the service, we can create an “alias” in nginx for the domain that points to a temporary folder.

If we create the folder /tmp/letsencrypt-auto

In the domain configuration in nginx we’ll add inside server { }:

[...]

  location /.well-known/acme-challenge {
    default_type "text/plain";
    root        /tmp/letsencrypt-auto;
  }

[...]

With a reload of nginx (without service downtime) we’ll have this configured.

With this, any request to domain/.well-known/acme-challenge will be answered by the content of our /tmp/letsencrypt-auto folder

So we’ll generate it with

certbot certonly --webroot -w /tmp/letsencrypt-auto -d mydomain.com

From this moment on, we can automate the certificate renewal by putting in the crontab a

certbot renew

NOTE: It’s also important to put a task in the crontab to reload the nginx, because otherwise, even if we have the renewed certificate, nginx won’t be using the updated certificate but the previous one.

Comments

Latest Posts

12 min

2449 words

I recently came across an exceptionally dense technical analysis about container security that’s worth sharing. The author started with a simple hypothesis: container filesystem isolation should be sufficient for multi-tenant workloads without virtual machines, if you sufficiently understand what’s happening at the syscall level.

After thorough investigation, the conclusion is more uncomfortable than expected: the defaults protect you well, but the moment you reach for “advanced” features like bidirectional mount propagation or SELinux relabeling, you’re one misconfiguration away from handing an attacker the keys to your host.

5 min

952 words

Vercel has announced the general availability of Vercel Sandbox, an execution layer designed specifically for AI agents. But beyond the AI agent hype, there’s an interesting question: can it be useful for running code safely in different languages like PHP, Node, or Go?

What is Vercel Sandbox?

Vercel Sandbox provides on-demand Linux microVMs. Each sandbox is isolated, with its own filesystem, network, and process space. You get sudo access, package managers, and the ability to run the same commands you’d run on a Linux machine.