Sunshine and Moonlight Streaming
Steam Headless integrates Sunshine, the industry-standard, open-source implementation of NVIDIA's GameStream protocol, alongside its native browser-based streaming portal. While the native WebRTC/WebSocket portal provides zero-install streaming in any web browser, Sunshine provides an ultra-low-latency streaming pipeline purpose-built for the Moonlight client ecosystem across desktop PCs, the Steam Deck, mobile devices, smart TVs, and handheld gaming consoles.
Through the web interface, Sunshine is managed as a first-class appliance service: its administrative interface is proxied securely behind unified session authentication, Moonlight clients are paired via a web-based PIN workflow, and video encoders are automatically tuned to your host hardware.
1. The Authenticated Reverse Proxy
In a standard standalone installation, Sunshine exposes an unauthenticated or independently passworded web interface on port 47990. In Steam Headless, port 47990 is never exposed to external networks.
Reverse Proxy Architecture
The web interface provides a built-in, authenticated reverse proxy accessible under the primary port at:
https://<container-ip>:8483/sunshine/pin
Key Security and Integration Benefits
- Single Sign-On (SSO): You log in once using your
steamheadlessappliance credentials. The web server manages Sunshine's internal credentials automatically via systemd private credential storage. - Strict CSRF Protection: Sunshine retains its secure loopback-only CSRF configuration because all requests arrive from
127.0.0.1. - No Port Sprawl: Network administrators only need to expose port 8483 for web management, rather than configuring firewall rules for separate web interfaces.
- Themed Embedding: The web interface injects a customised dark-theme stylesheet into the embedded Sunshine interface, stripping redundant navigation headers and harmonising the visual presentation with PrimeVue design standards.
Sunshine Navigation Tabs
When opening Sunshine in the web interface, the sub-navigation bar provides five dedicated views:
- PIN (
/sunshine/pin): Pair new Moonlight client devices. - Applications (
/sunshine/applications): Create, edit, and organise application launchers and custom commands. - Configuration (
/sunshine/configuration): Fine-tune video encoders, audio sinks, and network packet sizing. - Featured apps (
/sunshine/featured-apps): Explore community launcher presets and client download links. - Troubleshooting (
/sunshine/troubleshooting): Inspect Sunshine's internal logs and client handshake diagnostics.
2. Pairing Moonlight Clients: Step-by-Step Walkthrough
Moonlight uses a secure, certificate-based cryptographic handshake verified by a four-digit PIN. To pair a new client device:
Step 1: Install and Launch Moonlight
Install Moonlight on your gaming client:
- Desktop: Windows, macOS, and Linux (available via Flathub, native packages, or portable AppImage).
- Handhelds: Steam Deck (Flathub), ROG Ally, Legion Go, Nintendo Switch (homebrew).
- Mobile & TV: iOS, iPadOS, tvOS (Apple TV), Android, Android TV, and Fire TV.
Step 2: Discover or Add Your Steam Headless Host
When you open Moonlight on the same local network, it automatically discovers your Steam Headless container using mDNS and shows its configured Moonlight name.
If your Moonlight device is on an isolated Wi-Fi VLAN where mDNS multicast is blocked, click the Add Host manually button in Moonlight and enter the container's dedicated macvlan IP address (for example, 192.168.8.91).
Step 3: Generate the Pairing PIN in Moonlight
Click on the discovered Steam Headless host tile in Moonlight. A modal dialogue will appear displaying a randomly generated 4-digit PIN (for example: 7419) and wait for authorization.
+------------------------------------+
| Connect to Host |
| |
| Please enter the following PIN |
| on the host PC to pair: |
| |
| 7419 |
| |
| [ Cancel ] |
+------------------------------------+
Step 4: Authorise the PIN in the Web Interface
- In your web browser, open the PIN interface:
https://<container-ip>:8483/sunshine/pin. - Enter the four-digit PIN displayed on your Moonlight client into the PIN input field.
- Click Send.
+-----------------------------------------------------------------------+
| Sunshine PIN |
| --------------------------------------------------------------------- |
| Enter the 4-digit PIN displayed in Moonlight to complete pairing: |
| |
| PIN: [ 7419 ] [ Send ] |
+-----------------------------------------------------------------------+
Step 5: Verification and Playback
Within two seconds, Sunshine validates the certificate exchange. In Moonlight, the padlock icon on the host tile unlocks, changing to a green computer icon. Click the host to view available applications (Desktop and Steam Big Picture) and start streaming immediately.
3. Video and Audio Configuration
Sunshine's streaming parameters can be adjusted via the Configuration tab (/sunshine/configuration) in the web interface.
Hardware Video Encoder Selection
Steam Headless automatically detects your host GPU during container startup and selects the optimal hardware encoding profile:
| Hardware Platform | Recommended Encoder | Kernel Driver / Stack | Characteristics |
|---|---|---|---|
| Intel Core (Gen 8+) & Arc | VA-API (iHD) | intel-media-driver | High-throughput hardware H.264/HEVC/AV1 encoding with sub-millisecond latency. |
| Intel Core (Gen 4–7) / Iris Pro | VA-API (i965) | libva-intel-driver | Hardware H.264 encoding for older Broadwell/Skylake graphics hardware. |
| AMD Radeon Graphics | VA-API (radeonsi) | Mesa Gallium VA-API | High-fidelity hardware encoding across RDNA and Vega GPUs. |
| NVIDIA GeForce / RTX | NVENC | NVIDIA Container Toolkit / CUDA | Industry-leading hardware encoding with dual-encoder NVENC support. |
| Software CPU Fallback | OpenH264 / x264 | CPU Execution (Diagnostic Only) | High CPU overhead; intended only for diagnostic validation. |
When you connect with Moonlight, Sunshine instructs the headless KWin Wayland compositor to resize the virtual desktop dynamically to match the client's requested resolution and refresh rate (such as 2560x1440 at 120 Hz). You do not need to configure virtual monitor resolutions manually.
Target Frame Rates and Bitrate Recommendations
Moonlight supports adaptive bitrates and high refresh rates:
| Stream Target | Target Resolution | Recommended Refresh Rate | Recommended Bitrate | Network Requirement |
|---|---|---|---|---|
| Handheld / Mobile | 1280x720 / 1280x800 | 60 FPS | 10 – 15 Mbps | 5 GHz Wi-Fi / 4G LTE |
| Standard 1080p | 1920x1080 | 60 FPS | 20 – 30 Mbps | 5 GHz Wi-Fi / Ethernet |
| Competitive Esports | 1920x1080 | 120 / 144 / 240 FPS | 35 – 50 Mbps | Low-latency Ethernet |
| Quad HD (1440p) | 2560x1440 | 60 / 120 FPS | 40 – 60 Mbps | Gigabit Ethernet |
| Ultra HD (4K) | 3840x2160 | 60 / 120 FPS | 60 – 100 Mbps | Gigabit Ethernet |
Low-Latency Audio and Multi-Channel Surround Sound
Sunshine hooks into the container-local PipeWire sound server via a dedicated virtual sink (sunshine-sink):
- Audio Codec: Streams 128–512 kbps low-delay Opus audio packets directly to Moonlight.
- Surround Sound Configurations:
- Stereo (2.0): Standard two-channel audio for handhelds and laptops.
- 5.1 Surround: Six-channel surround sound for home theatre setups.
- 7.1 Surround: Eight-channel surround sound for advanced AV receiver setups.
- Automatic Switching: When a client requests 5.1 surround in Moonlight settings, Sunshine automatically reconfigures PipeWire's digital sink to six channels.
4. Managing Applications and Game Launchers
By default, Sunshine exposes two pre-configured applications:
- Desktop: Boots directly into the KDE Plasma Wayland desktop, giving you full control over your files, browser, and desktop applications.
- Steam Big Picture: Launches Steam in full-screen controller-optimised Big Picture mode.
Adding Custom Launchers via the Web UI
You can add dedicated launcher entries for standalone games, emulators, or Flatpak applications:
- Go to Sunshine → Applications (
/sunshine/applications) in the web interface. - Click Add New.
- Fill in the application fields:
- Application Name: e.g.,
RetroArchorHeroic Games Launcher. - Command (
cmd): The execution command (for example:flatpak run org.libretro.RetroArchorsteam -gamepadui). - Working Directory: Optional execution path.
- Image Path: An icon or cover art file located within the container.
- Application Name: e.g.,
- Click Save. The new entry will appear immediately in Moonlight.
Managing Application Definitions via apps.json
Sunshine stores its application catalogue in a simple JSON file on persistent storage:
/home/steamheadless/.config/sunshine/apps.json
Because /home/steamheadless is mounted from a persistent Docker volume, you can edit this file directly on the host or inside the container:
{
"env": {
"PATH": "$(PATH):/usr/bin:/app/bin"
},
"apps": [
{
"name": "Desktop",
"image-path": "desktop.png"
},
{
"name": "Steam Big Picture",
"output": "",
"cmd": "steam steam://open/bigpicture",
"image-path": "steam.png"
},
{
"name": "Heroic Games Launcher",
"output": "",
"cmd": "flatpak run com.heroicgameslauncher.hgl",
"image-path": "heroic.png"
}
]
}
5. Configuration Persistence and Overrides
All paired Moonlight certificates, custom application shortcuts, and Sunshine configuration parameters are stored in:
/home/steamheadless/.config/sunshine/
├── apps.json # Custom application entries
├── sunshine.conf # Hardware encoder, audio, and network tuning
└── credentials/ # Paired client TLS certificates and encryption keys
Automatic vs User-Managed Configuration
By default, Steam Headless sets Sunshine's capture, encoder, and renderer options on every container boot. This keeps Sunshine and the browser streaming pipeline on the same encoder GPU in a split-GPU setup.
Follow the SUNSHINE_ENABLE_AUTO_CONFIG option before selecting a different renderer in Sunshine's interface. Essential web proxy and authentication settings remain managed even when the rest of the Sunshine configuration is user-managed.
For comprehensive details on manual encoder flags and ownership boundaries, read Advanced Sunshine Configuration.
Sunshine currently presents remote controllers to games as standard Xbox 360-style controllers. Normal controls and rumble work, but controller-specific extras such as gyro, touchpads, battery reporting, and adaptive triggers are not currently passed through. Do not mount the host's /dev/input, /dev/hidraw*, or /run/udev into the container to work around this, because those mounts would break the input separation between desktops.
6. Sunshine Troubleshooting Summary
| Symptom | Probable Cause | Diagnostic & Resolution |
|---|---|---|
| Moonlight cannot discover host | Host firewall blocking ports or container on different subnet | Check macvlan routing; ensure UDP ports 47998–48010 and TCP port 47989 are open on host firewall. |
| PIN verification fails or times out | Four-digit PIN entered incorrectly or timed out in Moonlight | Generate a fresh PIN in Moonlight and submit it within 60 seconds at /sunshine/pin. |
| Stream starts but screen is black | DRM render node permissions or Wayland screencast stall | Verify /dev/dri/renderD128 access; check GPU and Encoding Troubleshooting. |
| No audio in Moonlight stream | PipeWire digital sink unlinked or muted | Go to Services and Logs and restart pipewire.service. |
| Video stuttering or high frame latency | Network packet loss or CPU scheduling contention | Inspect Work Capacity for elevated CPU pressure; reduce stream bitrate in Moonlight. |
Next Steps
- To audit systemd service health, inspect Sunshine runtime logs, or perform service restarts, read Services and Logs.
- To monitor container CPU pressure, memory headroom, and GPU engine utilisation, read Work Capacity.
- For detailed network port mappings and advanced encoder configurations, read Advanced Sunshine Configuration.