Skip to content

Turning old Samsung Galaxy M11 to a web hosting cloud server for extra storage

Notifications You must be signed in to change notification settings

Chabhinay/Old_Android_Web_Server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 

Repository files navigation


Personal Web Server on a Rooted Samsung Galaxy M11

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]

Goals

  • 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.

Environment and Tools

  • 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-distro in Termux.[1]
  • Web server: Nginx inside Debian.
  • Storage bridge: Symlink from Debian to Android shared storage created through Termux’s termux-setup-storage mechanism.[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]

Step 1: Termux and Debian Setup

  1. Install Termux from F‑Droid and update packages:
pkg update
pkg upgrade -y
  1. Grant Termux access to Android shared storage:
termux-setup-storage

This creates ~/storage/shared pointing to /storage/emulated/0 (Downloads, DCIM, etc.).[2][8]

  1. Install proot-distro and Debian:
pkg install proot-distro
proot-distro install debian
proot-distro login debian
apt update
apt upgrade -y
  1. Inside Debian, create a link to Android shared storage:
ln -s /data/data/com.termux/files/home/storage/shared /root/shared
ls /root/shared

Now /root/shared in Debian shows the same files as the phone’s internal storage.[3][8]


Step 2: Nginx Installation and Minimal Config

  1. Install Nginx in Debian:
apt install nginx -y
  1. Backup and rewrite the main config:
cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf.backup
nano /etc/nginx/nginx.conf

Minimal 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 usual www-data user cannot read Termux/Android storage in this setup.[3]
  1. 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/default
server {
    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;
    }
}
  1. Test and start Nginx:
nginx -t
service nginx start
  1. Create a simple test page and verify locally:
echo "Hello From my Android server" > /root/shared/index.html
curl http://localhost:8080/

Step 3: LAN Access and Networking Issues

  • 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]


Step 4: Rooting the Samsung Galaxy M11

To get full control over firewall rules and system behavior, the Galaxy M11 was rooted.[5][6]

High‑level steps (PC + phone):

  1. Unlock bootloader using Samsung’s Download Mode “OEM unlock” flow (this wipes the device).[6][11]
  2. Install Samsung USB drivers and Odin on the PC.[6]
  3. Download the correct TWRP .tar for Galaxy M11 (M115F), plus a Samsung multidisabler ZIP and Magisk ZIP.[4][12][5]
  4. Boot phone to Download Mode and flash TWRP via Odin in the AP slot.[4][7]
  5. 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 Data to remove encryption and fix 0MB storage issues on /data.[5]
  • Reboot → Recovery to 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.


Step 5: Firewall Rules for Port 8080

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 ACCEPT

These 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.


Step 6: Final Server Test

  1. Start Debian and Nginx:
proot-distro login debian
service nginx start
  1. 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.

Lessons Learned

  • Termux plus proot-distro provides 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-storage and 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

About

Turning old Samsung Galaxy M11 to a web hosting cloud server for extra storage

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published