Suppose we have a custom domain name called pi.xtestgo.xyz
configured and ready to use with LocalXpose (see previous tutorials, e.g., Create a custom domain). Now, it is time to use it on our Raspberry Pi.
1. SSH into the Raspberry Pi
ssh pi@192.168.1.11
2. Download LocalXpose
wget https://api.localxpose.io/api/v2/downloads/loclx-linux-arm.zip
3. Unzip LocalXpose
unzip loclx-linux-arm.zip
4. Create a systemd unit file
To keep LocalXpose running in the background and on boot, we need to create a unit file
nano localxpose.service
Paste the following contents into your unit file and save it.
[Unit]
Description=localxpose
After=network-online.target
[Service]
ExecStart=/home/pi/loclx tunnel http --reserved-domain pi.xtestgo.xyz --to 8000
Restart=always
RestartSec=15
[Install]
WantedBy=multi-user.target
Replace the domain and the port with yours.
5. Copy the service file to system directory
sudo cp localxpose.service /etc/systemd/system/
6. Reload the systemd manager
sudo systemctl daemon-reload
7. Login through the CLI
sudo ./loclx account login
This will ask you to enter your access token, which you can copy from your LocalXpose dashboard (opens in a new tab).
8. Enable the service to be run on boot
sudo systemctl enable localxpose.service
9. Run LocalXpose service
sudo systemctl start localxpose.service
Now, you may test your configuration as you would with any manual CLI command, except in this case you can be sure it will always be started automatically!
Join thousands of developers who rely on LocalXpose every day for their home automation, IT tools and security systems.
Free plan available • No credit card required