SSL with LetsEncrypt

Having your use the secure https:// protocol is pretty much mandatory for any modern web service. This requires a SSL/TLS certificate.

This is easy to fix declaratively via your NixOs configuration.

How to enable

Find your Nginx declaration (usually on site.nix).

If you use one of the starters that come with Shipnix, you will find the variable httpsEnabled at the top.

Change this to true, commit, push and click the Deploy button on your server dashboard.

{ config, lib, pkgs, ... }:
# TODO: Enable SSL/HTTPS when your domain records are hooked up
# By enabling SSL, you accept the terms and conditions of LetsEncrypt
- httpsEnabled = false;
+ httpsEnabled = true;

For a demo of how it works, look at this example

Explore the nginx options on NixOS

When adding certificates fail

Your domain record must be fully propagated to point to your server. So the first job will be to hook up your server with domain records.

If you encounter a warning like this, it probably means your domain records are not yet fully propagated, but it doesn’t hurt to double check your records.

warning: the following units failed:

× - Renew ACME certificate for
     Loaded: loaded (]8;;file://your-project/etc/systemd/system/]8;;; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Wed 2022-08-10 11:29:48 UTC; 117ms ago
TriggeredBy: ●
    Process: 164630 ExecStart=/nix/store/ (code=exited, status=10)
   Main PID: 164630 (code=exited, status=10)
         IP: 54.3K in, 20.9K out
        CPU: 103ms

Aug 10 11:29:48 your-project[164635]: 2022/08/10 11:29:48 Could not obtain certificates:
Aug 10 11:29:48 your-project[164635]:         error: one or more domains had a problem:

Your NixOS configuration will fail. If that happens, just re-disable https and try to enable it a bit later.