Reverse proxy and HTTPS
Serve ChronoSlice over HTTPS with Caddy or nginx, and set the two settings that go with it.
ChronoSlice speaks plain HTTP on 127.0.0.1:7340. A reverse proxy on the same server takes the public HTTPS traffic and passes it on. This page gives a working Caddy setup and a working nginx setup, then the two ChronoSlice settings that go with them.
What the proxy has to do
- Pass requests to
127.0.0.1:7340and handle the certificate. - Keep the
Hostheader as the browser sent it. ChronoSlice refuses a change made from a browser when the page's address doesn't match theHostheader it receives. If the proxy replacesHostwith127.0.0.1:7340, every save fails with "You don't have permission to do that." - Allow uploads of about 10 MB. Invoice attachments can be up to 10 MB each.
- Not buffer the live updates stream. The web app and the Mac app keep
/api/orgs/{org}/eventsopen and pull when the server says something changed. It's a server-sent events stream, and the server sends a keep-alive every 20 seconds.
Open ports 80 and 443 in your firewall. Don't open 7340.
Caddy
Caddy gets and renews certificates by itself and keeps the Host header. It passes the live updates stream through as it is, so nothing else is needed. Install Caddy from its Debian repository (see caddyserver.com/docs/install), then put this in /etc/caddy/Caddyfile:
time.example.com {
encode zstd gzip
reverse_proxy 127.0.0.1:7340
}
Reload it:
sudo systemctl reload caddy
nginx
Get a certificate first, with Certbot or your usual tool. The paths below are where Certbot puts them. Put this in /etc/nginx/sites-available/chronoslice and link it into sites-enabled:
server {
listen 80;
server_name time.example.com;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl;
http2 on;
server_name time.example.com;
ssl_certificate /etc/letsencrypt/live/time.example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/time.example.com/privkey.pem;
client_max_body_size 11m;
location / {
proxy_pass http://127.0.0.1:7340;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Proto $scheme;
}
# Live updates (server-sent events): don't hold the stream back.
location ~ ^/api/orgs/[^/]+/events$ {
proxy_pass http://127.0.0.1:7340;
proxy_set_header Host $http_host;
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_buffering off;
}
}
Check the file and reload:
sudo nginx -t && sudo systemctl reload nginx
Three lines in that file matter:
proxy_set_header Host $http_host;passes the address on exactly as the browser sent it. Without it, nginx sends127.0.0.1:7340and saving anything in the browser fails with a 403.$hostworks too while nginx listens on 443, but it drops any other port, with the same 403.client_max_body_size 11m;raises nginx's 1 MB default, which would reject invoice attachments.proxy_buffering off;on the events path. ChronoSlice doesn't send anX-Accel-Buffering: noheader, so nginx is left to decide, and with buffering on it holds the live updates back. In a test on nginx 1.31, nothing arrived at all when the browser connected over HTTP/1.1, and other people's changes only showed after a reload. Over HTTP/2 the events happened to get through, but don't rely on it.
Tell ChronoSlice about the address
Two settings in /etc/chronoslice/env go with HTTPS:
CHRONOSLICE_PUBLIC_URL=https://time.example.com
CHRONOSLICE_SECURE_COOKIES=true
CHRONOSLICE_PUBLIC_URLis the address people reach ChronoSlice at. Emails use it for links to invoices, Stripe sends clients back to it, and it's the base of the Stripe webhook address. A trailing slash is removed. Without it, emails can't link to invoices and the Stripe webhook can't be set up.CHRONOSLICE_SECURE_COOKIES=truemarks the session cookie Secure, so browsers send it only over HTTPS. Usetrue, not1oryes. Leave it off only while you test over plain HTTP, because a browser won't keep a Secure cookie from anhttp://address.
Restart ChronoSlice after changing them:
sudo systemctl restart chronoslice
Check it
curl -sI https://time.example.com | head -1
You should see HTTP/2 200. Then open the address in a browser. A new install shows the setup page. See The first account.
If sign-in works but saving anything fails, the proxy is changing the Host header. See Troubleshooting.
Still stuck?
Send us a request: it goes to the people who build ChronoSlice, and the reply comes by email. Include your ChronoSlice version (Settings › Licence shows it) and what you tried.