# Sunshine + Moonlight Remote Gaming

Stream and play PC games remotely with near-zero latency using Sunshine (host) and Moonlight (client) on Clore.ai's GPU-powered servers.

{% hint style="info" %}
**Sunshine** is an open-source, self-hosted game streaming server with 20,000+ GitHub stars. **Moonlight** is the free, open-source client that connects to it. Together they rival GeForce NOW — at a fraction of the cost.
{% endhint %}

***

## What Is Sunshine + Moonlight?

**Sunshine** is a fork of the original Moonlight/GameStream stack, now fully independent and actively maintained by LizardByte. It captures your GPU output, encodes it in real-time using H.264/H.265/AV1, and streams it over the network with ultra-low latency.

**Moonlight** is the client app available for Windows, macOS, Linux, Android, iOS, Raspberry Pi, and even some smart TVs.

### Why Use It on Clore.ai?

* **Rent a high-end GPU** (RTX 4090, A100, etc.) at spot pricing
* **Stream AAA games** from the cloud to any device — even a cheap laptop
* **No GeForce NOW subscription** needed — you control the hardware
* **Game modding, AI-assisted gameplay**, or game development testing on powerful hardware

***

## Prerequisites

| Requirement      | Details                                   |
| ---------------- | ----------------------------------------- |
| Clore.ai account | With sufficient CLORE balance             |
| GPU server       | NVIDIA GPU (for NVENC encoding) preferred |
| Moonlight client | Installed on your local device            |
| SSH access       | For initial setup                         |

***

## Step 1: Rent a GPU Server on Clore.ai

1. Go to [clore.ai](https://clore.ai) → **Marketplace**
2. Filter by **GPU type**: RTX 3080 or better recommended for 1080p/60fps streaming
3. Look for servers with ports **22**, **47990**, and **48010** available
4. Select a server and proceed to order

{% hint style="warning" %}
**Port requirements**: Sunshine needs ports 47990 (HTTPS web UI) and 48010 (streaming). Make sure these are listed in the server's available ports before ordering.
{% endhint %}

### Recommended GPU for Streaming

| Resolution | Target FPS | Minimum GPU     |
| ---------- | ---------- | --------------- |
| 1080p      | 60 fps     | RTX 3060        |
| 1440p      | 60 fps     | RTX 3080        |
| 4K         | 60 fps     | RTX 3090 / 4080 |
| 1080p      | 120 fps    | RTX 4070+       |

***

## Step 2: Deploy Sunshine via Docker

### Docker Compose (Recommended)

Create a file `docker-compose.yml`:

```yaml
version: "3.8"

services:
  sunshine:
    image: lizardbyte/sunshine:latest
    container_name: sunshine
    restart: unless-stopped
    privileged: true
    network_mode: host
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=UTC
      - SUNSHINE_USERNAME=admin
      - SUNSHINE_PASSWORD=your_secure_password
    volumes:
      - ./sunshine-config:/config
      - /tmp/.X11-unix:/tmp/.X11-unix:rw
      - /dev/dri:/dev/dri
    devices:
      - /dev/dri:/dev/dri
    deploy:
      resources:
        reservations:
          devices:
            - driver: nvidia
              count: all
              capabilities: [gpu]
```

### Start the Container

```bash
# Pull and start
docker compose up -d

# Check logs
docker compose logs -f sunshine

# Verify it's running
docker ps | grep sunshine
```

{% hint style="success" %}
**First boot**: Sunshine takes \~30 seconds to initialize. Watch the logs for "Sunshine started successfully" before proceeding.
{% endhint %}

### Single Docker Command (Quick Start)

```bash
docker run -d \
  --name sunshine \
  --restart unless-stopped \
  --privileged \
  --network host \
  -e SUNSHINE_USERNAME=admin \
  -e SUNSHINE_PASSWORD=changeme \
  -v $(pwd)/sunshine-config:/config \
  -v /tmp/.X11-unix:/tmp/.X11-unix \
  --device /dev/dri:/dev/dri \
  --gpus all \
  lizardbyte/sunshine:latest
```

***

## Step 3: Configure Sunshine Web UI

1. Open your browser and navigate to:

   ```
   https://<your-clore-server-ip>:47990
   ```
2. Accept the self-signed certificate warning
3. Log in with the credentials you set (`admin` / `your_secure_password`)

{% hint style="warning" %}
**HTTPS only**: Sunshine's web UI runs on HTTPS. Your browser will show a certificate warning — this is expected. Click "Advanced" → "Proceed" to continue.
{% endhint %}

### Web UI Sections

| Section           | Purpose                               |
| ----------------- | ------------------------------------- |
| **Pin**           | Pair with Moonlight client            |
| **Applications**  | Define streamable apps/games          |
| **Configuration** | Encoder, resolution, bitrate settings |
| **Logs**          | Debug streaming issues                |

***

## Step 4: Configure Encoding Settings

Navigate to **Configuration** → **Video** in the web UI:

### Recommended Settings for Clore.ai

```
# Encoder
encoder: nvenc          # Use NVIDIA hardware encoding

# Resolution
resolution_width: 1920
resolution_height: 1080

# Frame rate
fps: 60

# Bitrate
bitrate: 50000          # 50 Mbps for 1080p60 — excellent quality

# H.265 (better compression, use if client supports it)
codec: hevc
```

{% hint style="info" %}
**NVENC vs VAAPI**: On Clore.ai NVIDIA servers, always use `nvenc` encoder. It offloads encoding to the GPU hardware, freeing CPU for the game itself.
{% endhint %}

### Bitrate Guide

| Quality   | Resolution | Bitrate   |
| --------- | ---------- | --------- |
| Good      | 1080p60    | 20 Mbps   |
| Great     | 1080p60    | 35 Mbps   |
| Excellent | 1080p60    | 50 Mbps   |
| Great     | 1440p60    | 50 Mbps   |
| Excellent | 4K60       | 100+ Mbps |

***

## Step 5: Add Applications to Stream

In the Sunshine web UI → **Applications** → **Add New**:

### Example: Desktop Streaming

```
Name: Desktop
Command: (leave empty for full desktop)
Working Directory: /home/user
```

### Example: Steam Game

```
Name: Steam Big Picture
Command: steam -bigpicture
Working Directory: /home/user
Detach Command: (empty)
```

### Example: Custom Game

```
Name: My Game
Command: /opt/games/mygame/start.sh
Working Directory: /opt/games/mygame
Image: /opt/games/mygame/cover.png
```

***

## Step 6: Set Up Virtual Display (Headless Server)

Clore.ai servers are headless (no physical monitor). You need a virtual display:

```bash
# Install virtual display driver
apt-get update && apt-get install -y xvfb x11vnc xfce4

# Create virtual display
Xvfb :1 -screen 0 1920x1080x24 &
export DISPLAY=:1

# Start desktop environment
startxfce4 &
```

### Or Use a Virtual Framebuffer Script

```bash
#!/bin/bash
# start-display.sh

export DISPLAY=:1

# Start virtual display
Xvfb :1 -screen 0 1920x1080x24 -ac +extension GLX +render -noreset &
sleep 2

# Start window manager
openbox &
sleep 1

# Start Sunshine
docker compose up -d sunshine
```

Make it executable and run:

```bash
chmod +x start-display.sh
./start-display.sh
```

{% hint style="info" %}
**NVIDIA GPU with no display**: Add the following to your Sunshine config to use the GPU without a physical display:

```bash
export __GL_SYNC_TO_VBLANK=0
export __GL_GSYNC_ALLOWED=0
```

{% endhint %}

***

## Step 7: Connect with Moonlight Client

### Install Moonlight

| Platform     | Download                                                 |
| ------------ | -------------------------------------------------------- |
| Windows      | [moonlight-stream.org](https://moonlight-stream.org)     |
| macOS        | Mac App Store or moonlight-stream.org                    |
| Linux        | `flatpak install flathub com.moonlight_stream.Moonlight` |
| Android      | Google Play Store                                        |
| iOS          | App Store                                                |
| Raspberry Pi | `apt install moonlight-embedded`                         |

### Pair Moonlight with Sunshine

1. Open Moonlight on your local device
2. Click **Add PC** and enter your Clore.ai server IP
3. Moonlight will display a **PIN code**
4. Go to Sunshine Web UI → **Pin** → enter the PIN
5. Connection established! ✅

### Moonlight Settings for Best Experience

```
Resolution: 1920x1080
FPS: 60
Bitrate: 50 Mbps
Video codec: HEVC (H.265)
Hardware decoding: Enabled
Audio: Stereo
```

***

## Step 8: Port Forwarding Reference

| Port        | Protocol | Purpose                   |
| ----------- | -------- | ------------------------- |
| 22          | TCP      | SSH management            |
| 47984       | TCP      | HTTPS (GameStream compat) |
| 47989       | TCP      | HTTP (GameStream compat)  |
| 47990       | TCP      | HTTPS Web UI              |
| 48010       | TCP      | RTSP (streaming control)  |
| 47998-48000 | UDP      | Video/Audio streaming     |
| 48010       | UDP      | Video streaming           |

{% hint style="warning" %}
**Clore.ai port mapping**: When ordering your server, ensure ports 47990 and 48010 are in your port map. UDP ports for streaming (47998-48000) should also be available if possible.
{% endhint %}

***

## Troubleshooting

### Sunshine Won't Start

```bash
# Check container logs
docker logs sunshine --tail 50

# Common fix: permissions
chmod 777 /tmp/.X11-unix
xhost +local:docker
```

### Black Screen When Streaming

```bash
# Verify virtual display is running
export DISPLAY=:1
xdpyinfo | grep dimensions

# Restart display
pkill Xvfb
Xvfb :1 -screen 0 1920x1080x24 &
```

### High Latency

* Switch from **Wi-Fi to Ethernet** on client side
* Reduce bitrate in Moonlight settings
* Use **H.265** instead of H.264 (better compression at same quality)
* Enable **Frame Pacing** in Sunshine config

### NVENC Error: "No encoder found"

```bash
# Verify NVIDIA GPU is accessible
nvidia-smi

# Check container has GPU access
docker exec sunshine nvidia-smi

# If not, restart with --gpus all flag
docker stop sunshine && docker rm sunshine
# Re-run with --gpus all
```

### Authentication/Pairing Issues

```bash
# Reset Sunshine credentials
docker exec sunshine sunshine --creds admin newpassword

# Clear paired clients
rm -f ./sunshine-config/sunshine_state.json
docker restart sunshine
```

***

## Advanced Configuration

### Multi-Monitor Support

```yaml
# In Sunshine config (sunshine.conf)
[video]
adapter_name = /dev/dri/card0
output_name = HDMI-A-1
```

### Audio Over Network

Install PulseAudio virtual sink:

```bash
apt-get install -y pulseaudio
pulseaudio --daemon
pactl load-module module-null-sink sink_name=virtual_sink
export PULSE_SERVER=unix:/run/user/1000/pulse/native
```

### Game Controller Support

Sunshine supports virtual gamepad emulation. Enable in config:

```yaml
[input]
gamepad = enabled
ds4_back_as_touchpad_click = disabled
```

### Wake-on-LAN (for persistent servers)

```bash
# Keep server alive even when not streaming
docker update --restart=always sunshine
```

***

## Cost Optimization

### Calculate Your Streaming Cost

```
GPU rental: ~$0.30-0.80/hour (RTX 3080)
Storage: ~$0.01/hour (50GB SSD)
Total: ~$0.31-0.81/hour

vs GeForce NOW: $9.99-$19.99/month (limited hours)
vs Xbox Cloud Gaming: $14.99/month (limited catalog)
```

### Tips to Save Money

1. **Spot instances**: Use cheapest available GPU during off-peak hours
2. **Pause when not gaming**: Stop the container but keep the volume
3. **Pre-install games**: Use a persistent volume so you don't re-download each time
4. **Auto-shutdown**: Add a script to stop the server after inactivity

```bash
# Auto-shutdown after 30 min of no Moonlight connection
#!/bin/bash
while true; do
  connections=$(ss -tn | grep 47990 | wc -l)
  if [ "$connections" -eq 0 ]; then
    idle_count=$((idle_count + 1))
  else
    idle_count=0
  fi
  if [ "$idle_count" -ge 30 ]; then
    echo "No connections for 30 min, shutting down"
    docker stop sunshine
    break
  fi
  sleep 60
done
```

***

## Security Best Practices

{% hint style="danger" %}
**Never expose Sunshine without authentication!** Always set a strong password and consider using a VPN or SSH tunnel for additional security.
{% endhint %}

### SSH Tunnel Method (Most Secure)

```bash
# On your local machine, create SSH tunnel
ssh -L 47990:localhost:47990 \
    -L 48010:localhost:48010 \
    root@<clore-server-ip>

# Then connect Moonlight to localhost instead of the server IP
```

### Change Default Credentials

```bash
docker exec sunshine sunshine --creds admin 'Y0urStr0ngP@ssw0rd!'
```

### Restrict Access by IP

In Sunshine config:

```
allowed_ips = 192.168.1.0/24,203.0.113.5
```

***

## Performance Benchmarks

| GPU      | Resolution | FPS | Latency | Encoder   |
| -------- | ---------- | --- | ------- | --------- |
| RTX 3060 | 1080p      | 60  | \~15ms  | NVENC     |
| RTX 3080 | 1440p      | 60  | \~12ms  | NVENC     |
| RTX 4080 | 4K         | 60  | \~10ms  | NVENC AV1 |
| RTX 4090 | 4K         | 120 | \~8ms   | NVENC AV1 |

*Latency measured on 100 Mbps local network connection*

***

## Useful Links

* [Sunshine GitHub](https://github.com/LizardByte/Sunshine) — 20K+ stars
* [Moonlight Official Site](https://moonlight-stream.org)
* [Sunshine Documentation](https://docs.lizardbyte.dev/projects/sunshine)
* [LizardByte Discord](https://discord.gg/lizardbyte)
* [Clore.ai Marketplace](https://clore.ai)

***

## Summary

| Step | Action                                      |
| ---- | ------------------------------------------- |
| 1    | Rent GPU server with ports 22, 47990, 48010 |
| 2    | Deploy `lizardbyte/sunshine` via Docker     |
| 3    | Configure via web UI at `https://IP:47990`  |
| 4    | Set NVENC encoder, 50 Mbps bitrate          |
| 5    | Create virtual display (Xvfb)               |
| 6    | Install Moonlight client locally            |
| 7    | Pair using PIN code                         |
| 8    | Stream and game! 🎮                         |

With Sunshine + Moonlight on Clore.ai, you get a cloud gaming experience that rivals any commercial service — with full control over your hardware and games. No subscriptions, no restrictions, no limits.

***

## Clore.ai GPU Recommendations

| Use Case                  | Recommended GPU | Est. Cost on Clore.ai |
| ------------------------- | --------------- | --------------------- |
| 1080p/60fps Streaming     | RTX 3090 (24GB) | \~$0.12/gpu/hr        |
| 4K/High-refresh Streaming | RTX 4090 (24GB) | \~$0.70/gpu/hr        |
| AAA Gaming + Streaming    | RTX 4090 (24GB) | \~$0.70/gpu/hr        |

> 💡 All examples in this guide can be deployed on [Clore.ai](https://clore.ai/marketplace) GPU servers. Browse available GPUs and rent by the hour — no commitments, full root access.
