skirl

Behind a reverse proxy

Browsers and phones allow push notifications only over HTTPS, and Skirl serves plain HTTP: a reverse proxy in front of it holds the certificate. To set one up from an empty folder, follow your proxy's section of the installation guide (Cloudflare Tunnel, Traefik, Caddy or nginx): every file whole, and a check after every step. This page is the reference: what any proxy must do, and each proxy's tested configuration with the command that shows it took.

What any proxy must do#

Pass the Host header through, say that the visitor came over HTTPS (X-Forwarded-Proto) and who they are (X-Forwarded-For), let WebSockets through, not buffer responses, and keep idle connections open for at least a minute.

You do not have to get this right by reading. Open Skirl through the proxy and run the setup wizard's connection test (step 3, or Run setup again in Admin → Diagnostics later). It checks each of those from your browser, names the proxy it finds, and shows the exact lines to add for it. When the proxy passes on the visitor's address or HTTPS but proxy mode is off, the check fails and offers Trust this proxy, which turns proxy mode on, so rate limits and sign-ins see each visitor's own address (Skirl is behind a reverse proxy).

The configurations below are the wizard's own (they come from the same table), CI runs each against the real proxy, and copies are in deploy/. They expect Skirl on the same machine at 127.0.0.1:8080 (in Docker: ports: ["127.0.0.1:8080:8080"]; as a binary: SKIRL_LISTEN=127.0.0.1:8080). For a proxy in Docker, use Skirl's container name instead, such as skirl:8080.

Whatever the proxy, this is the check that it works, from any computer:

curl -s https://notify.example.com/v1/health
{"healthy":true}

nginx#

Put this in /etc/nginx/conf.d/skirl.conf, with your host name and certificate. Every line in the location block matters; the wizard says which one is missing.

server {
    listen 443 ssl;
    server_name notify.example.com;
    ssl_certificate /etc/letsencrypt/live/notify.example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/notify.example.com/privkey.pem;
    location / {
        proxy_pass http://127.0.0.1:8080;
        proxy_http_version 1.1;
        proxy_set_header Host $http_host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_buffering off;
        proxy_read_timeout 300s;
    }
}

Check the configuration, then load it:

sudo nginx -t && sudo systemctl reload nginx

nginx -t ends with nginx: configuration file /etc/nginx/nginx.conf test is successful. Then the health check above.

Caddy#

Caddy gets the certificate and passes everything on by itself; this is the whole Caddyfile entry:

notify.example.com {
	reverse_proxy 127.0.0.1:8080
}

Load it:

sudo systemctl reload caddy

systemctl status caddy shows active (running), and the health check above answers once the certificate is there (a few seconds the first time).

Traefik#

A router and a service for Traefik's file provider (providers.file in the static configuration). Add a certificate resolver under tls: if Traefik should get the certificate. For Traefik in Docker, the labels in the installation guide's Traefik section do the same.

http:
  routers:
    skirl:
      rule: Host(`notify.example.com`)
      service: skirl
      tls: {}
  services:
    skirl:
      loadBalancer:
        servers:
          - url: http://127.0.0.1:8080

Traefik reads the file provider's changes by itself. Its dashboard (when on) lists the router skirl as enabled, and the health check above answers.

If Traefik itself sits behind another proxy (a load balancer, Cloudflare), it replaces their forwarded headers: trust that proxy on Traefik's entry point (forwardedHeaders.trustedIPs). The wizard notices and shows the lines.

Nginx Proxy Manager#

Edit the proxy host, point it at Skirl's address and port 8080, and switch on Websockets Support. Then the health check above. If a check in the wizard still fails, it shows nginx lines to paste into the proxy host's Advanced box.

Cloudflare#

Through a Cloudflare Tunnel, follow the installation guide's Cloudflare Tunnel section: the tunnel sends the name straight to the container, and WebSockets and Skirl's streams pass without extra settings.

With Cloudflare's proxy (the orange cloud) in front of your own proxy instead, WebSockets must be on for the domain (Network settings). If a check still fails behind Cloudflare, the proxy between Cloudflare and Skirl needs the fix: pick it in the wizard under "Show for another proxy".

Flags#

The wizard keeps the public address and the proxy setting in the database. If you would rather fix them at start-up, --base-url, --behind-proxy and --trusted-proxies (or SKIRL_BASE_URL, SKIRL_BEHIND_PROXY, SKIRL_TRUSTED_PROXIES) win over the stored values, and the web app shows them as fixed, naming the flag or variable: Configuration variables.

This page on GitHub