Skip to content

Commit c635f1b

Browse files
authored
Create synology-setup.md
1 parent 617e137 commit c635f1b

1 file changed

Lines changed: 146 additions & 0 deletions

File tree

docs/synology-setup.md

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
# Synology NAS Setup
2+
3+
Run Matrix on a Synology NAS so every device in your household can access it (locally or remotely) with full tile caching and offline support.
4+
5+
## Prerequisites
6+
7+
- Synology NAS running DSM 7+
8+
- Python 3 installed (DSM packages or community)
9+
- [Tailscale](https://tailscale.com/kb/1131/synology) package installed on the NAS
10+
- Tailscale installed on each device that will access the app
11+
- MagicDNS and HTTPS certificates enabled in your Tailscale admin console
12+
13+
## 1. Copy the app to your NAS
14+
15+
Copy the repository to your Synology home folder (via SSH, File Station, or git):
16+
17+
```bash
18+
ssh your-nas
19+
cd ~/apps
20+
git clone <repo-url> matrix
21+
```
22+
23+
## 2. Launch the server
24+
25+
```bash
26+
cd ~/apps/matrix
27+
python3 serve.py
28+
```
29+
30+
On first run, vendor dependencies are downloaded automatically. Verify the app works by visiting `http://your-nas-ip:8765` from a device on your LAN.
31+
32+
## 3. Configure Tailscale Serve
33+
34+
Tailscale Serve creates an HTTPS reverse proxy with a real Let's Encrypt certificate. This is required because Service Workers (used for tile caching) only register on secure origins.
35+
36+
**Default (port 443):**
37+
38+
```bash
39+
sudo tailscale serve --bg http://localhost:8765
40+
```
41+
42+
This serves at `https://your-nas.tail1234.ts.net` (no port suffix). Works if nothing else on the NAS is using port 443.
43+
44+
**Custom port (if DSM occupies 443):**
45+
46+
```bash
47+
sudo tailscale serve --bg --https=8443 http://localhost:8765
48+
```
49+
50+
This serves at `https://your-nas.tail1234.ts.net:8443`.
51+
52+
`--bg` runs it persistently in the background. Verify the config:
53+
54+
```bash
55+
sudo tailscale serve status
56+
```
57+
58+
You should see output like:
59+
60+
```
61+
https://your-nas.tail1234.ts.net (tailnet only)
62+
|-- / proxy http://127.0.0.1:8765
63+
```
64+
65+
This is a **one-time command**. The config persists across reboots — Tailscale's daemon remembers it.
66+
67+
**To remove the config:**
68+
69+
```bash
70+
# Default port:
71+
sudo tailscale serve / off
72+
73+
# Custom port:
74+
sudo tailscale serve --https=8443 / off
75+
```
76+
77+
Verify with `sudo tailscale serve status` — it should show no config.
78+
79+
## 4. Access the app
80+
81+
From any device on your tailnet, open:
82+
83+
```
84+
https://your-nas.tail1234.ts.net
85+
```
86+
87+
Or if using a custom port:
88+
89+
```
90+
https://your-nas.tail1234.ts.net:8443
91+
```
92+
93+
Find your exact hostname by running `tailscale status` on the NAS, or check the [Tailscale admin console](https://login.tailscale.com/admin/machines).
94+
95+
No port forwarding needed — Tailscale uses encrypted WireGuard tunnels that punch through NAT automatically.
96+
97+
## 5. Auto-start on boot
98+
99+
The Tailscale serve config survives reboots on its own. You only need to ensure `serve.py` starts when the NAS boots.
100+
101+
**DSM → Control Panel → Task Scheduler:**
102+
103+
1. Click **Create → Triggered Task → User-defined script**
104+
2. **General tab:**
105+
- Task name: `Matrix`
106+
- User: `root` (or your user account)
107+
- Event: **Boot-up**
108+
3. **Task Settings tab:**
109+
- Command:
110+
```
111+
cd /volume1/homes/<your-user>/apps/matrix && python3 serve.py
112+
```
113+
4. Click **OK**
114+
115+
## 6. Verify everything works
116+
117+
After setup, confirm these features work from a remote device:
118+
119+
| Feature | How to verify |
120+
|---|---|
121+
| App loads | Visit the Tailscale HTTPS URL |
122+
| Service Worker | DevTools → Application → Service Workers shows "activated and running" |
123+
| Photo upload | Drop a photo → check `matrix-photos/` on NAS has the image + thumbnail |
124+
| Tile caching | Pan/zoom the map → check `matrix-tiles/` on NAS starts populating |
125+
| Offline mode | Disconnect from internet → cached map tiles and photos still display |
126+
127+
## Troubleshooting
128+
129+
**"Site can't be reached"**
130+
- Is Tailscale running on both the NAS and your device?
131+
- Are both on the same tailnet? Check `tailscale status` on each.
132+
133+
**Redirected to DSM login page**
134+
- Port 443 is taken by DSM. Use port 8443 (or another unused port) for Tailscale Serve.
135+
136+
**Service Worker not registering**
137+
- Confirm you're accessing via `https://` (the Tailscale URL), not `http://`.
138+
- Check DevTools → Console for SW registration errors.
139+
140+
**Tiles not caching to disk**
141+
- After a fresh install or SW update, clear the tile cache: Settings gear → Empty Map Cache, then hard refresh (`Cmd+Shift+R`).
142+
- Check that the `matrix-tiles/` directory exists and has write permissions.
143+
144+
**Thumbnails not rendering**
145+
- Ensure `serve.py` was running when the photo was uploaded (thumbnails are saved to disk during auto-save).
146+
- If thumbnails are missing, re-upload the affected photos.

0 commit comments

Comments
 (0)