
Turned my old MSI gaming laptop into a production Rails server, $0/month hosting using Cloudflare Tunnel
Had an old gaming laptop collecting dust. Instead of selling it, I wiped Windows 11 and set it up as a proper production server. Here's the full setup and what I ran into.
What's running:
- Ubuntu Server 24.04 LTS
- Rails 8 + Puma + Sidekiq + Redis
- PostgreSQL + pgvector (AI embeddings)
- Nginx as reverse proxy
- Cloudflare Tunnel for public HTTPS
- Custom domain
Total cost: ~₹800/year (domain only)
Previously running on AWS EC2 + RDS. Shut it all down today.
The interesting problems I ran into:
1. CGNAT
My ISP uses CGNAT so port forwarding is impossible. Cloudflare Tunnel solved this completely, your server connects outbound to Cloudflare, no inbound ports needed. Works perfectly behind any NAT.
2. ISP DNS blocking
The server's default DNS (router) wasn't resolving api.openai.com correctly. Switching to 1.1.1.1 via resolvectl fixed it.
3. systemd EnvironmentFile
Getting env vars to load properly into systemd services was surprisingly annoying. systemctl show --property=Environment shows empty even when the file is loading correctly — it only shows inline Environment= directives, not EnvironmentFile contents. Check via /proc/{pid}/environ instead.
4. pgvector permissions
Installing pgvector on Ubuntu 24.04 with a non-superuser PostgreSQL role throws permission errors even after CREATEDB. Had to grant SUPERUSER to the app user to get migrations running.
Specs:
- Old gaming laptop
- 8GB RAM
- ~470GB SSD
- Idle memory with full stack: ~730MB (9%)
Happy to answer questions about any part of the setup.