Please do not use an OctoPi image, as it can cause unforeseen (avoidable) problems.
Please check and modify the username, if you do not use the user pi, you have to replace it in each path and in the variable User in the service files.
Don’t forget to enable SSH and configure a network if using Wi-Fi.
It is recommended to use a clean Raspberry Pi OS 32-bit Lite image. If you don't use a Raspberry Pi as SBC, every default Debian Buster / Bullseye (recommended) should also fit with this guide.
We recommend you follow the Raspberry Pi OS official documentation to flash and install the operating system to your SD card.
Once you have finished the installation and are connected via SSH, you can continue.
Requirements
Install the required packages and update the system:
Please pay attention to the following steps!
A very common source of errors are improperly configured trusted_clients.
For Moonraker you’ll need to create a separate config file.
nano ~/printer_data/config/moonraker.conf
Insert the following part:
[server]host:0.0.0.0port:7125# The maximum size allowed for a file upload (in MiB). Default 1024 MiBmax_upload_size:1024# Path to klippy Unix Domain Socketklippy_uds_address:~/printer_data/comms/klippy.sock[file_manager]# post processing for object cancel. Not recommended for low resource SBCs such as a Pi Zero. Default Falseenable_object_processing:False[authorization]cors_domains:*://my.mainsail.xyz*://*.local*://*.lantrusted_clients:10.0.0.0/8127.0.0.0/8169.254.0.0/16172.16.0.0/12192.168.0.0/16FE80::/10::1/128# enables partial support of Octoprint API[octoprint_compat]# enables moonraker to track and store print history.[history]# this enables moonraker announcements for mainsail[announcements]subscriptions:mainsail# this enables moonraker's update manager[update_manager]refresh_interval:168enable_auto_refresh:True[update_manager mainsail]type:webchannel:stablerepo:mainsail-crew/mainsailpath:~/mainsail
This is a very basic config
For more options and detailed explanations you should follow Moonraker’s instructions.
Trusted Clients - read carefully
A list of newline separated IP addresses and/or IP ranges that are trusted. Trusted clients are given full access to the API. Both IPv4 and IPv6 addresses and ranges are supported. Ranges must be expressed in CIDR notation (see CIDR for more info).
For example, an entry of 192.168.1.0/24 will authorize IP addresses in the range of 192.168.1.1 - 192.168.1.254. Note that when specifying IPv4 ranges the last segment of the IP address must be 0. The default is no clients or ranges are trusted.
Save the file with CTRL+O and close the editor with CTRL+X.
Startup service
To edit this file type:
sudonano/etc/systemd/system/moonraker.service
fill in these lines:
#Systemd moonraker Service[Unit]Description=API Server for Klipper SV1Requires=network-online.targetAfter=network-online.target[Install]WantedBy=multi-user.target[Service]Type=simpleUser=piSupplementaryGroups=moonraker-adminRemainAfterExit=yesWorkingDirectory=/home/pi/moonrakerEnvironmentFile=/home/pi/printer_data/systemd/moonraker.envExecStart=/home/pi/moonraker-env/bin/python $MOONRAKER_ARGSRestart=alwaysRestartSec=10
Save the file with CTRL+O and close the editor with CTRL+X.
Next step, you have to create an Klipper environment file in your printer_data:
Now you can recheck the API to see if it works with the reverse proxy. Open the URL http://<printer-ip>/server/info in your browser. If you see content like this:
Use hostname instead of IP to open Mainsail (optional)
To use the hostname instate of the IP, you can install the avahi-daemon:
sudo apt install avahi-daemon
And you can config your hostname:
sudo raspi-config
In 2 Network Options > N1 Hostname, you can edit the hostname of your Raspberry Pi. After a reboot, you can use http://<hostname>.local/ to open the web interface.