Run Unsloth Studio behind a Caddy reverse proxy, accessible over the internet via a custom domain.
Internet
|
v
[DNS: your-domain.com] --> your public IP
|
v
[Caddy] (Docker, host network mode, port 443/80)
|
v
[Unsloth Studio] (local, 192.168.x.x:8000)
Caddy handles TLS termination (automatic HTTPS via Let's Encrypt) and proxies requests to Unsloth Studio running on your local machine.
- Docker and Docker Compose installed
- A public domain with DNS A record pointing to your machine's public IP
- Port 80 and 443 open on your router/firewall
Unsloth Studio is checked on each start and the installer is run so it can install or upgrade the CLI if needed.
cp .env.example .envEdit .env with your values:
| Variable | Description | Default |
|---|---|---|
STUDIO_HOST |
Local IP of the machine running Studio | 192.168.x.x |
STUDIO_PORT |
Port Unsloth Studio listens on | 8000 |
DOMAIN |
Public domain for reverse proxy | your-domain.com |
Create an A record for your domain pointing to your public IP address. You can use a service like No-IP or DuckDNS if your ISP gives you a dynamic IP.
Ports 80 and 443 must be reachable from the internet. Forward these to your machine in your router settings.
Alternative: Cloudflare Tunnel Unsloth Studio can be exposed via Cloudflare Tunnel without opening ports. However, the tunnel URL regenerates on every restart, making it impractical for stable remote access. The Caddy + port forwarding approach recommended above provides a persistent URL.
# Start both Caddy and Unsloth Studio in the background
./run.sh start
# Check if services are running
./run.sh status
# View Unsloth Studio logs (live tail)
./run.sh logs
# Restart both services
./run.sh restart
# Stop both services
./run.sh stop- Caddy runs in a Docker container with
network_mode: host, giving it direct access to your machine's network. It automatically provisions TLS certificates for your domain via Let's Encrypt. - Unsloth Studio runs as a background process managed by
run.sh. Process IDs are tracked in.pids/and logs are written tologs/.
For production environments, you can run the Unsloth Stack components as separate systemd services.
An example Type=simple service file is provided at systemd/unsloth-studio.service.example.
To use it:
-
Copy the example service file to the systemd directory:
sudo cp systemd/unsloth-studio.service.example /etc/systemd/system/unsloth-studio.service
-
Edit
/etc/systemd/system/unsloth-studio.serviceto match your environment:- Update
WorkingDirectoryto the path of your unsloth-stack directory - Update
EnvironmentFileto point to your.envfile - Update the log file paths in
StandardOutputandStandardError - Update
UserandGroupto the non-root user and group that should run the service
- Update
-
Reload systemd and start the service:
sudo systemctl daemon-reload sudo systemctl enable unsloth-studio.service sudo systemctl start unsloth-studio.service -
Check the service status:
sudo systemctl status unsloth-studio.service
An example service file for starting the Caddy Docker Compose service is provided at systemd/caddy-proxy.service.example.
To use it:
-
Copy the example service file to the systemd directory:
sudo cp systemd/caddy-proxy.service.example /etc/systemd/system/caddy-proxy.service
-
Edit
/etc/systemd/system/caddy-proxy.serviceto match your environment:- Update
WorkingDirectoryto the path of your unsloth-stack directory - Update
EnvironmentFileto point to your.envfile - Update the
ExecStartandExecStoppaths to match the location of yourdocker-compose.ymlfile - Update
UserandGroupto the non-root user and group that should run the service. Note: The user must be a member of thedockergroup to rundocker composecommands.
- Update
-
Reload systemd and start the service:
sudo systemctl daemon-reload sudo systemctl enable caddy-proxy.service sudo systemctl start caddy-proxy.service -
Check the service status:
sudo systemctl status caddy-proxy.service
| File | Description |
|---|---|
run.sh |
Management script (start/stop/restart/status) |
docker-compose.yml |
Docker Compose config for Caddy |
Caddyfile |
Caddy reverse proxy configuration |
.env.example |
Template for environment configuration |
.env |
Your local configuration (not committed) |
Check the logs:
./run.sh logs
# or directly:
cat logs/unsloth-studio.logVerify Unsloth Studio is listening on the expected address:
curl http://192.168.x.x:8000Check Caddy logs:
docker logs caddy-proxy- Ensure DNS A record is correct:
dig your-domain.com - Ensure ports 80/443 are open and forwarded to your machine
- Caddy logs will show certificate provisioning status:
docker logs caddy-proxy
Clean up stale PID files:
rm -f .pids/unsloth-studio.pid
./run.sh start