08 October 2026 · 2 min read
Running a web server on an Android STB without root
Used Android TV boxes are cheap and surprisingly capable for lightweight sites. The key is Termux: a Linux environment that runs without root. Here is the outline I use to host a real website on one.
Basic setup
Install Termux from F-Droid (not the Play Store, whose build is outdated), then update packages and install the core components.
pkg update && pkg upgrade
pkg install nginx php-fpm mariadb cloudflared termux-services
Run nginx and PHP-FPM on a port above 1024, such as 8080, because unrooted Android does not allow low ports. That is fine since public access will go through a tunnel.
Public access without opening ports
Home connections usually sit behind CGNAT, so port forwarding is not an option. Cloudflare Tunnel solves this: cloudflared makes an outbound connection to Cloudflare, and HTTPS traffic is forwarded to your local nginx.
cloudflared tunnel login
cloudflared tunnel create stb
cloudflared tunnel route dns stb site.example.com
cloudflared tunnel run --url http://127.0.0.1:8080 stb
Making it resilient
- Auto-start: install Termux:Boot and put a script in
~/.termux/boot/to start nginx, PHP-FPM, MariaDB, and the tunnel when the device powers on. - Storage: keep MariaDB data on an adoptable SD card so internal memory is not used up.
- Backups: schedule a daily
mysqldumpand copy it off the device. - Security: enable Cloudflare WAF rules and rate limits, and restrict access to phpMyAdmin.
Wrapping up
The result is a public HTTPS website with zero hosting cost. It will not replace a large production server, but as a lab and a lightweight host it beat my expectations.