Skip to content

Instantly share code, notes, and snippets.

@fermino
Last active April 4, 2026 05:15
Show Gist options
  • Select an option

  • Save fermino/4f903422a9599a06cf48ebf94980e0d0 to your computer and use it in GitHub Desktop.

Select an option

Save fermino/4f903422a9599a06cf48ebf94980e0d0 to your computer and use it in GitHub Desktop.
Mainsail on Caddy Web Server
# DO NOT EXPOSE YOUR PRINTER ON THE INTERNET!
# This is inteded to be used with a local domain and a private ACME server like
# step-ca, or with self-signed certificates.
# Tweak your domain and the root folder for mainsail accordingly.
# This path will work out of the box with https://aur.archlinux.org/packages/mainsail-git
# You might also want to enable HSTS, if you know what you're doing.
{
admin off
email <your_email>
acme_ca https://<your_step_ca>/<acme_prover>/acme/directory
}
(hsts) {
header Strict-Transport-Security max-age=31536000;
}
myprinter.home.arpa {
vars {
moonraker_host "127.0.0.1"
moonraker_port 7125
}
@proxy path /websocket /printer/* /api/* /access/* /machine/* /server/*
handle @proxy {
reverse_proxy {vars.moonraker_host}:{vars.moonraker_port}
#import hsts
}
handle {
file_server
root /usr/share/webapps/mainsail
try_files {path} /index.html
header Cache-Control "no-store, no-cache, must-revalidate"
#import hsts
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment