Remote Access¶
Access your DataSci Homelab from anywhere using Cloudflare Tunnel.
Overview¶
Cloudflare Tunnel creates a secure connection between your homelab and Cloudflare's network, allowing you to access RStudio and JupyterLab from anywhere without:
- Opening ports on your router
- Setting up dynamic DNS
- Managing SSL certificates
- Exposing your home IP address
Prerequisites¶
- A domain name (can be free from Cloudflare)
- A Cloudflare account (free tier works)
cloudflaredCLI installed locally
Setup Guide¶
Step 1: Install cloudflared¶
# Debian/Ubuntu
curl -L https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64.deb -o cloudflared.deb
sudo dpkg -i cloudflared.deb
# Or download binary directly
curl -L https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64 -o cloudflared
chmod +x cloudflared
sudo mv cloudflared /usr/local/bin/
Download from Cloudflare releases
Step 2: Authenticate with Cloudflare¶
This opens a browser window. Select the domain you want to use.
Step 3: Create a Tunnel¶
This outputs a tunnel ID and creates a credentials file at:
Save the tunnel ID — you'll need it.
Step 4: Configure DNS¶
# Create DNS record for RStudio
cloudflared tunnel route dns datasci-homelab rstudio.yourdomain.com
# Create DNS record for Jupyter
cloudflared tunnel route dns datasci-homelab jupyter.yourdomain.com
Step 5: Create Configuration¶
Create ~/.cloudflared/config.yml:
tunnel: <your-tunnel-id>
credentials-file: /Users/yourname/.cloudflared/<tunnel-id>.json
ingress:
- hostname: rstudio.yourdomain.com
service: http://localhost:8787
- hostname: jupyter.yourdomain.com
service: http://localhost:8888
- service: http_status:404
Paths Must Be Absolute
Use full paths in the credentials-file field.
Step 6: Start the Tunnel¶
Step 7: Access Remotely¶
Open in any browser:
https://rstudio.yourdomain.comhttps://jupyter.yourdomain.com
Running as a Service¶
macOS (launchd)¶
Linux (systemd)¶
Now the tunnel starts automatically on boot.
Security Considerations¶
Authentication¶
Enable Authentication
With remote access enabled, never run with DISABLE_AUTH=true.
Always set strong passwords:
Cloudflare Access (Recommended)¶
Add an extra authentication layer via Cloudflare Access:
- Go to Cloudflare Zero Trust dashboard
- Create an Access Application
- Add your domain patterns:
rstudio.yourdomain.comjupyter.yourdomain.com- Configure authentication:
- Email OTP (free)
- Google/GitHub OAuth
- Or other identity providers
This adds a login page before users even reach RStudio/Jupyter.
IP Restrictions¶
In Cloudflare Access, you can restrict access to:
- Specific countries
- IP ranges
- Only authenticated users
Troubleshooting¶
Tunnel Not Connecting¶
# Check tunnel status
cloudflared tunnel list
cloudflared tunnel info datasci-homelab
# Test locally first
curl http://localhost:8787
curl http://localhost:8888
502 Bad Gateway¶
The service isn't running or accessible:
# Verify container is running
docker-compose ps
# Check services are listening
docker-compose exec homelab curl http://localhost:8787
Certificate Errors¶
Cloudflare handles SSL automatically. If you see cert errors:
- Wait a few minutes for DNS propagation
- Clear browser cache
- Try incognito mode
DNS Not Resolving¶
Alternative: SSH Tunneling¶
If you can't use Cloudflare Tunnel:
From Remote Machine¶
# Forward RStudio
ssh -L 8787:localhost:8787 user@your-server
# Forward both
ssh -L 8787:localhost:8787 -L 8888:localhost:8888 user@your-server
Then access http://localhost:8787 on your local machine.
Persistent SSH Tunnel¶
Use autossh:
Alternative: Tailscale¶
Tailscale is another excellent option:
- Install Tailscale on your server
- Install Tailscale on your devices
- Access via Tailscale IP:
http://100.x.x.x:8787
Benefits:
- No domain required
- Zero configuration
- Works behind NAT
- Free for personal use
Mobile Access¶
Both RStudio Server and JupyterLab work on mobile browsers:
- iPad: Full functionality
- iPhone/Android: Works but cramped
For the best mobile experience:
- Use a tablet
- Enable authentication
- Consider Cloudflare Access for extra security
Multi-User Access¶
If multiple people need access:
Option 1: Shared Credentials¶
Everyone uses the same username/password. Simple but no isolation.
Option 2: Multiple Containers¶
Run separate containers for each user:
# docker-compose-user1.yml
services:
homelab-user1:
ports:
- "8787:8787"
- "8888:8888"
environment:
- RSTUDIO_USER=user1
Option 3: RStudio Server Pro / JupyterHub¶
For true multi-user with isolation, consider:
- RStudio Server Pro (paid)
- JupyterHub (free, but more complex)
Bandwidth Considerations¶
Data science workflows can transfer significant data:
| Operation | Typical Size |
|---|---|
| Loading notebook | 1-10 MB |
| Rendering plot | 0.1-5 MB |
| Large dataset preview | 10-100 MB |
| PDF download | 1-20 MB |
For remote access over slow connections:
- Work with sampled data remotely
- Download full results rather than streaming
- Consider running heavy jobs locally and accessing results remotely