This project turns an old Android phone (Samsung Galaxy M11) into a small web server that can serve files over a local network. It uses Termux, a Debian container via proot-distro, and Nginx. Later, the phone is rooted so that firewall rules and storage access can be fully controlled.[1][2]
- Reuse an old Android phone as a personal “cloud” / file server on the LAN.
- Serve files directly from Android shared storage using a Linux web stack.
- Learn practical Linux, networking, and Android internals along the way.
- Device: Samsung Galaxy M11 (Android 11).
- App: Termux from F‑Droid (Play Store version is outdated and not recommended).[2]
- Container: Debian installed via
proot-distroin Termux.[1] - Web server: Nginx inside Debian.
- Storage bridge: Symlink from Debian to Android shared storage created through Termux’s
termux-setup-storagemechanism.[3][2] - Root: Bootloader unlocked, TWRP installed, and Magisk used for root access on the phone.[4][5][6]
- PC tools: ADB/fastboot, Samsung USB drivers, Odin, and Android platform‑tools.[6][4][7]
- Install Termux from F‑Droid and update packages:
pkg update
pkg upgrade -y- Grant Termux access to Android shared storage:
termux-setup-storageThis creates ~/storage/shared pointing to /storage/emulated/0 (Downloads, DCIM, etc.).[2][8]
- Install
proot-distroand Debian:
pkg install proot-distro
proot-distro install debian
proot-distro login debian
apt update
apt upgrade -y- Inside Debian, create a link to Android shared storage:
ln -s /data/data/com.termux/files/home/storage/shared /root/shared
ls /root/sharedNow /root/shared in Debian shows the same files as the phone’s internal storage.[3][8]
- Install Nginx in Debian:
apt install nginx -y- Backup and rewrite the main config:
cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf.backup
nano /etc/nginx/nginx.confMinimal working nginx.conf:
user root;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
events {
worker_connections 768;
}
http {
sendfile on;
tcp_nopush on;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
gzip on;
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}user root;is required because the usualwww-datauser cannot read Termux/Android storage in this setup.[3]
- Rewrite the default site to serve Android storage on port 8080:
cp /etc/nginx/sites-available/default /etc/nginx/sites-available/default.backup
nano /etc/nginx/sites-available/defaultserver {
listen 8080 default_server;
listen [::]:8080 default_server;
root /root/shared;
server_name localhost;
index index.html index.htm;
location / {
try_files $uri $uri/ =404;
autoindex on;
}
}- Test and start Nginx:
nginx -t
service nginx start- Create a simple test page and verify locally:
echo "Hello From my Android server" > /root/shared/index.html
curl http://localhost:8080/- The phone’s IP on Wi‑Fi is obtained via:
ip addr show wlan0- From another device on the same network, the server is accessed at:
http://<PHONE_IP>:8080/
Early on, hostel/campus Wi‑Fi blocked client‑to‑client traffic, so the web page was only visible on the phone itself. After switching to a different network / hotspot that allowed local connectivity, the same URL worked from a laptop as well.[9][10]
To get full control over firewall rules and system behavior, the Galaxy M11 was rooted.[5][6]
High‑level steps (PC + phone):
- Unlock bootloader using Samsung’s Download Mode “OEM unlock” flow (this wipes the device).[6][11]
- Install Samsung USB drivers and Odin on the PC.[6]
- Download the correct TWRP
.tarfor Galaxy M11 (M115F), plus a Samsung multidisabler ZIP and Magisk ZIP.[4][12][5] - Boot phone to Download Mode and flash TWRP via Odin in the AP slot.[4][7]
- Important: As soon as Odin shows PASS, force reboot directly into TWRP (Volume Up + Power) to avoid stock recovery overwriting TWRP, which is how Samsung firmware behaves by default.[4][13]
Inside TWRP:
Wipe → Format Datato remove encryption and fix 0MB storage issues on /data.[5]Reboot → Recoveryto re‑enter TWRP.- Flash Samsung multidisabler to disable forced‑encryption and verity checks.[5][14]
- Flash Magisk ZIP to install root.[6][5]
- Reboot to system and complete Magisk setup.
After boot, Magisk confirms root is active.
With root access on Android, iptables rules can be applied to make the Nginx port reachable from hotspot/Wi‑Fi clients even if the ROM enforces restrictive defaults.[15][9]
In Termux, after granting root:
su
# Allow incoming TCP connections to port 8080
iptables -I INPUT -p tcp --dport 8080 -j ACCEPT
# If needed, also allow traffic from the hotspot interface (e.g. ap0)
iptables -I INPUT -i ap0 -j ACCEPTThese rules remove firewall blocks that may prevent other devices connected to the phone’s hotspot from contacting the local web server.[15][9] Persistence across reboots can be handled later via Magisk boot scripts or a firewall app that applies rules at startup.
- Start Debian and Nginx:
proot-distro login debian
service nginx start- From another device on the LAN or hotspot, open:
http://<PHONE_IP>:8080/
The “Hello From my Android server” page loads successfully, confirming that:
- Termux and Debian are working.
- Nginx serves content from Android’s shared storage.
- Root‑level firewall rules allow LAN/hotspot clients to connect.
- Termux plus
proot-distroprovides a practical way to run a full Linux distribution on Android without needing root initially.[1][16] - Android’s storage model and app sandboxing require explicit bridging (
termux-setup-storageand symlinks) for a Linux container to see user files.[3][2] - Nginx on Android via Debian works smoothly if the configs are simplified and paths are carefully set to the shared storage.
- Public Wi‑Fi and some hotspots can block peer‑to‑peer connections, creating “it works on the phone but not on the laptop” symptoms that are purely network/firewall issues.[9][10]
- Rooting a Samsung device with TWRP and Magisk requires attention to Samsung‑specific behaviors (stock recovery overwrite, forced encryption) and tools like multidisabler to achieve a stable rooted setup.[4][12][5][14]
- Once rooted, Android can be treated more like a small Linux server, including custom iptables rules for port access and service exposure.[15][9]
Citations: [1] termux/proot-distro: An utility for managing installations ... https://github.com/termux/proot-distro [2] Termux-setup-storage https://wiki.termux.com/wiki/Termux-setup-storage [3] File transfer from proot-distro (Debian) to local storage or ... https://www.reddit.com/r/termux/comments/16blsqy/file_transfer_from_prootdistro_debian_to_local/ [4] [RECOVERY] TWRP 3.6.x.x for Samsung Galaxy M115F m11q https://xdaforums.com/t/recovery-twrp-3-6-x-x-for-samsung-galaxy-m115f-m11q.4617783/ [5] Complete Tutorial How to Root Galaxy M11 / A11 Using Magisk Root https://www.youtube.com/watch?v=AQu0LC92oy4 [6] How to Root Samsung Galaxy M11 using Magisk https://magiskzip.com/how-to-root-samsung-galaxy-m11-using-magisk/ [7] How to Install TWRP Recovery & Magisk Root on Android with Odin ... https://www.youtube.com/watch?v=BOfv0F12gSI [8] Internal and external storage - Termux Wiki https://wiki.termux.com/wiki/Internal_and_external_storage [9] How to open Port in Android device - Mobile Computing https://community.spiceworks.com/t/how-to-open-port-in-android-device/635310 [10] Android Question Internet access port 80? https://www.b4x.com/android/forum/threads/internet-access-port-80.131072/ [11] How To Root Samsung Galaxy M11 – Four 100% Working Methods! https://rootingmaster.com/root-samsung-galaxy-m11/ [12] Unofficial TWRP Recovery for Samsung Galaxy M11 | Root ... https://www.getdroidtips.com/twrp-recovery-samsung-galaxy-m11-root/ [13] How To Install TWRP Recovery On Any Samsung Using ODIN https://www.getdroidtips.com/flash-twrp-recovery-samsung-phone/ [14] Install TWRP Recovery on Samsung [multidisabler ... https://droidwin.com/install-twrp-recovery-samsung-galaxy-multidisabler-fbedisabler/ [15] How to open a port with iptables? https://manage.accuwebhosting.com/knowledgebase/5142/How-to-open-a-port-with-iptables-.html [16] [GUIDE][NO-ROOT]How to install Debian or Ubuntu ... https://xdaforums.com/t/guide-no-root-how-to-install-debian-or-ubuntu-environments-on-android-in-termux-using-proot-distro.4570275/page-3 [17] How to change working directory in Termux https://stackoverflow.com/questions/68515987/how-to-change-working-directory-in-termux [18] iptables redirect 80 to 8080 but block public 8080 access https://stackoverflow.com/questions/11065124/iptables-redirect-80-to-8080-but-block-public-8080-access [19] Can Proot be used to access Linux distribution from ... termux/proot#50 [20] How To Connect Internal Storage With Proot Distro https://www.youtube.com/watch?v=nFJ55atTzsA [21] Linux Port Forwarding Using iptables https://www.systutorials.com/port-forwarding-using-iptables/ [22] Running Linux on Android with Termux and Proot Debian https://www.facebook.com/groups/linux.fans.group/posts/25445816395033469/ [23] How To Root Android 11 With Magisk & Custom Recovery (TWRP) https://www.youtube.com/watch?v=isxtKSu0FCk