My daughter’s music app was fine all day. Then, between 5 and 7:30 pm, one song would take more than 40 seconds to download. The same song takes a quarter of a second on my home network.
I spent a day measuring each part of the path. The NAS was fine. The tunnel was fine. The slow part was the route from the phone to the CDN. This post shows how I found that, why I did not just pay for a bigger plan, and how I fixed it with a $5 relay server in Seoul.
The Problem: Slow Only at Dinner Time
The app is a small media player I host on a Synology DS224+ at home. It sits behind a free Cloudflare Tunnel, so I never open a port on my router. That setup worked well for months.
Then evenings got bad. Songs stalled. The first screen took ten seconds. Outside 5 to 7:30 pm it was usually fine, and it got better after I moved my router next to the NAS. But the evening slowness stayed.
My first guess was the tunnel itself. If the tunnel is the cause, I thought, nothing else I fix will help.
💬 Prompt that worked “The slowdown between 5 and 7:30 pm is still there. Outside those hours it is faster than before because I changed the router, but if the tunnel is the cause, nothing else helps. What if I look for another option only for the Kids Player project? What about Oracle or Amazon? Or should I switch to a paid Cloudflare account?”
That prompt did not ask for a fix. It asked for options. I think that was the right question, because my first guess about the cause turned out to be wrong.
The Proof: Same Song, Two Paths
This is the same 2.4 MB song, measured at about 10 pm, one path after the other.
| Old path (Cloudflare Tunnel) | New path (Seoul relay) | |
|---|---|---|
| One song (2.4 MB) | did not finish in 40 s (20–45 KB/s) | 0.22–0.36 s (7–11 MB/s) |
| Time to first byte | 1.3–1.9 s | 0.08–0.17 s |
| App first screen | 10.9 s | 0.1 s |
That is roughly a 200 times difference. At 10 pm, so it is not only a “peak hour” problem. I did not test the relay during the 5 to 7:30 pm window yet. I come back to that at the end.
The NAS did not change at all between the two columns.
Why I Needed This
My daughter is two. She taps a song, and if nothing plays in a few seconds she loses interest and walks away. A slow app is not “a bit annoying” for her. It is a broken app.
I also want the app to work for my family without me explaining anything. The rule I keep is: no open ports at home, no ads, no accounts on other people’s servers. So I did not want to move the whole library to a cloud disk. There are about 39 GB of media files on the NAS, and I want them to stay there.
How I Did It
Step 1: Measure each hop before guessing
I tested four things at the same time of evening.
1. The NAS itself. The DSM Resource Monitor showed CPU at 2%, memory at 24%, and network upload at 8 KB/s. The NAS was almost idle while the app felt broken.
2. The path inside my home. My nginx container also listens on port 8081, so I can reach the app without the tunnel:
curl -s -o /dev/null -w "ttfb=%{time_starttransfer}s total=%{time_total}s speed=%{speed_download}B/s\n" \
"http://<NAS-IP>:8081/path/to/song.mp3"
The song came down in 0.32 seconds (about 7 MB/s). The app and the disk were fine.
3. The tunnel. I read the cloudflared log:
sudo docker compose logs --tail 100 cloudflared
All four tunnel connections were registered to Seoul data centers (location=icn01 and icn06). There was one short outage the morning I moved the router (about 1 minute 40 seconds, with a DNS timeout in the same second, so my home internet had dropped). After that, nothing for about 29 hours. No reconnects. The tunnel was stable.
4. The path from the phone to the CDN. This was the surprise.
curl -sI https://your-app.example.com | grep -i cf-ray
The cf-ray ID ends with a data center code. Mine ended in LAX. That is Los Angeles. The same PC reaching Cloudflare’s own speed-test host got ICN (Seoul) and 9 to 13 MB/s.
Then I checked from my phone with Wi-Fi turned off. Open https://your-app.example.com/cdn-cgi/trace and read the colo= line. On mobile data it also said colo=LAX. So it was not only my home internet provider.
So: same company, same PC, two host names. One goes to Seoul, one goes to Los Angeles. As far as I can tell, the free plan’s address range is routed differently from the others, and my traffic crosses the Pacific twice for every request.
🗂 Claude.md Rule Slow only at certain hours → measure each hop with the same file, same time: (1) LAN direct port, (2) public URL, (3) tunnel log, (4)
cf-ray/colo=from PC and from phone on mobile data. Do not restart services before measuring.
I had also wondered if switching the tunnel protocol to HTTP/2 would help. The log said the QUIC connections were healthy for 29 hours, so I dropped that idea. It would not touch a problem that lives before the tunnel.
Step 2: Choose the fix
I looked at four options.
- Cloudflare Pro, about $20 a month. Some people say better plans get better routing. I read reports in both directions, including a user who upgraded and still saw the far route. I could not find a source that says Pro moves Korean traffic to Seoul. I did not want to pay $20 for a guess.
- Move everything to a big cloud provider. My media is 39 GB, and the owner of the data would no longer be my NAS. Data transfer fees add up too.
- Oracle or Amazon free tiers. Free is nice, but I have read stories of free accounts being suspended, and I did not want my daughter’s app to depend on that.
- A small relay server in Seoul. The NAS stays the source of truth. The relay only forwards requests. Cost: about $5.
I chose the relay. The path becomes:
phone → relay server in Seoul → Tailscale → NAS (nginx on port 8081) → app
The relay does not store the media. It passes requests to the NAS through Tailscale. No port is opened at home.
Step 3: Create the server
I tried Amazon Lightsail first. The sign-up asked for an account plan, free credits, support plan and MFA, and I could not find the $5 instance on the sign-up screens. I stopped there and did not create any instance. I switched to Vultr, whose sign-up is much shorter. This is only about my own patience with sign-up screens, not about quality.
On Vultr, three mistakes nearly cost me money:
- The create screen first showed a Dedicated CPU plan: $0.06 per hour. That is about $44 a month, for a server that only forwards requests.
- A later screen had Bare Metal selected by accident. The price did not change when I changed other options, which was the clue.
- The cheapest plan, $2.50 a month, has
-v6in its name. That means IPv6 only. A phone or Wi-Fi without IPv6 could not reach it at all.
What I picked: Shared CPU, vc2-1c-1gb (1 vCPU, 1 GB RAM, 25 GB SSD, 1 TB transfer), Seoul, Ubuntu, IPv4, Automatic Backups off. $5.00 a month. The 0.5 GB plan at $3.50 would have worked, but I wanted room for installs.
🗂 Claude.md Rule Cloud server shopping: the plan name matters.
-v6= IPv6 only. “Dedicated CPU” and “Bare Metal” are not the cheap tier. Turn off auto backups. Read the Summary total before pressing Deploy.
Step 4: Lock it down and install three things
I logged in once with the root password Vultr showed me, added my own SSH key, and then did everything with the key.
# firewall: only SSH and web
ufw default deny incoming
ufw allow 22/tcp
ufw allow 80/tcp
ufw allow 443/tcp
ufw --force enable
apt install -y nginx certbot python3-certbot-nginx
curl -fsSL https://tailscale.com/install.sh | sh
tailscale up --hostname=relay-seoul
tailscale up prints a login link. Open it in a browser, sign in, approve. On the Synology I installed the Tailscale package from Package Center and signed in with the same account. Now both machines can reach each other.
From the relay I tested the NAS:
tailscale ping <NAS-TAILSCALE-IP>
curl -s -o /dev/null -w "%{http_code} %{time_total}s\n" http://<NAS-TAILSCALE-IP>:8081/path/to/song.mp3
The ping took 7 ms, and the song took 0.17 seconds. The Synology package says TUN mode: No (it runs in userspace mode), and it still worked for incoming requests.
Step 5: The nginx relay
server {
listen 80;
server_name test.example.com;
client_max_body_size 500m;
location / {
proxy_pass http://<NAS-TAILSCALE-IP>:8081;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_read_timeout 600s;
proxy_request_buffering off;
proxy_max_temp_file_size 256m;
}
}
Two small notes. X-Forwarded-Proto matters because my app only marks a login cookie Secure when it sees HTTPS. And I did not add any cache on purpose: some of my API paths are protected by a cookie, and a careless cache could hand a protected file to someone without the cookie. If I add a cache later, it will only be for public paths.
Step 6: Test on a second host name first
I did not touch the real address first. I added a test name test.example.com in DNS:
- Type A, pointing to the relay’s IPv4 address
- Proxy off (grey cloud, “DNS only”)
The grey cloud is the important part. With the orange cloud on, traffic goes back through the CDN and back to Los Angeles.
Then one command for HTTPS:
certbot --nginx -d test.example.com --non-interactive --agree-tos \
--register-unsafely-without-email --redirect
I ran the same song against both hosts, three times each. That is where the 200 times comes from.
Step 7: Move the real address
My real address was a CNAME to the tunnel, with the orange cloud on. Before changing it I wrote down the old value, because that is the rollback:
CNAME your-app → <TUNNEL-ID>.cfargotunnel.com (proxied)
I edited the record in place: type A, value the relay IP, proxy off. The dashboard warns that changing the type replaces the record, which is fine. I had already added the nginx block for the real name, so the certificate command worked a few seconds after DNS updated:
certbot --nginx -d your-app.example.com --non-interactive --agree-tos \
--register-unsafely-without-email --redirect
The phone app and its saved settings kept working, because the address did not change. I left the old tunnel running on the NAS as a backup. If the relay dies, I point the record back at the tunnel.
Step 8: Keep the two apps apart
I wanted to tell the test copy from the real one on the phone home screen. The relay can serve different files for the same app on different host names. For the test name only, I made a blue icon with a big “2” and a manifest named “Kids Player 2”, and told nginx to serve those two paths from a local folder:
location = /manifest.json { root /var/www/test; add_header Cache-Control "no-cache"; }
location ^~ /icons/ { root /var/www/test; add_header Cache-Control "no-cache"; }
The real address still shows the original icon. The NAS files did not change.
What I Want to Improve Next
- Test in the real window. My 200 times test and my daughter’s phone check were at about 10 pm. I will repeat the song test between 5 and 7:30 pm and write the numbers here.
- A cache for public files. Covers and songs that do not need a login could be cached on the relay. I want to do this with an allow-list, not a blanket rule.
- Know what depends on what. Now three things must be running: the relay, Tailscale, and the NAS. I wrote the rollback steps in my project notes and I want a simple uptime check on the relay.
- Remove my own access. I used a temporary SSH key for the setup. I will delete that key from the server when I am done.
Cost
| Item | Cost |
|---|---|
| Vultr relay server (1 vCPU, 1 GB, Seoul) | $5.00 per month |
| Vultr account deposit | $0 (card linked, pay as you go) |
| Tailscale (personal use) | $0 |
| HTTPS certificates (Let’s Encrypt) | $0 |
| Amazon account created, no server launched | $0 |
| Cloudflare Pro considered, not bought | $0 |
If you have the same symptom, you do not need my exact stack. The one thing I would copy is the order: measure the NAS, measure inside the house, read the tunnel log, then check which data center answers you. I lost an evening on the wrong guess, and the answer was one line in a response header.