Developers, privacy‑conscious users, and power users often need a lightweight HTTP proxy that runs directly on their phone. A local proxy can help you:
AdGuard Home without leaving the device.All of this can be achieved without rooting, thanks to the Termux environment and the tiny, well‑maintained tinyproxy package.
Prerequisites
Termux:API and Termux:Boot add‑ons for automation.Safety note: Tinyproxy will listen only on the loopback interface (127.0.0.1) by default, meaning no external device can reach it. Do not change the Listen address unless you understand the security implications.
pkg update && pkg upgrade -y
This ensures you get the latest apt metadata and avoids compatibility warnings.pkg install nano curl wget proot -y
nano is a simple editor; curl and wget will be used for testing.unstable-repo (required for Tinyproxy on some architectures):
pkg install unstable-repopkg install tinyproxy -y
Termux will pull the pre‑compiled binary and its minimal dependencies.tinyproxy -v
You should see a version string such as Tinyproxy/1.10.1./data/data/com.termux/files/usr/etc/tinyproxy.conf by default. Open the file with nano (it will be created if missing):
nano $PREFIX/etc/tinyproxy.conf# comments as needed):
# Tinyproxy minimal config for local use
User nobody
Group nogroup
Port 8888
Listen 127.0.0.1
MaxClients 100
Timeout 600
LogLevel Info
LogFile "${HOME}/tinyproxy.log"
Explanation of the key lines:
tinyproxy -c $PREFIX/etc/tinyproxy.conf
You should see a line like INFO: Tinyproxy 1.10.1 started on port 8888.curl -x 127.0.0.1:8888 -I https://httpbin.org/ip
If the proxy works, the response will include a JSON payload showing your public IP (the request still goes out to the internet, but Tinyproxy forwards it).cat ~/tinyproxy.log | tail -n 5
You should see a line containing GET https://httpbin.org/ip.nohup and &:
nohup tinyproxy -c $PREFIX/etc/tinyproxy.conf &
The process will detach and continue running after you close the session.ps -A | grep tinyproxy
You should see a line with the PID and the command.termux-wake-lock:
termux-wake-lock && nohup tinyproxy -c $PREFIX/etc/tinyproxy.conf &
Remember to release the lock later with termux-wake-unlock if you stop the proxy.127.0.0.1 and Port: 8888. Leave the Bypass proxy for field empty.Some apps (e.g., Chrome, Firefox) use their own proxy settings or ignore the system proxy. In those cases you can configure the proxy directly inside the app’s network preferences.
INFO: 127.0.0.1 - - "GET https://httpbin.org/headers"ps -A | grep tinyproxy).By default Tinyproxy permits the CONNECT method, which is required for HTTPS. If you disabled it in a custom config, re‑enable it:
Allow CONNECT 443
Place the line in tinyproxy.conf under the # Allow CONNECT comment.
To prevent other apps on the device from abusing the proxy, you can require a username and password:
BasicAuth user1 password123
After adding the line, restart Tinyproxy (kill the old PID and start a new one). When the system asks for credentials, enter the pair you defined.
iptablesIf you want only a handful of apps to use the proxy, you can redirect their traffic at the kernel level. This requires the iptables binary, which is available via the termux-root package on devices that allow rootless iptables (most recent Android versions do). Example for the app with package com.example.myapp:
iptables -t nat -A OUTPUT -p tcp -m owner --uid-owner $(pm list packages -3 | grep com.example.myapp | cut -d: -f2) --dport 80 -j REDIRECT --to-ports 8888
Because this command manipulates the network stack, it may require su on some devices. Use it only if you understand the impact.
Termux:Boot add‑on from F‑Droid.
pkg install termux-api termux-boot -ymkdir -p $HOME/.termux/boot
cat > $HOME/.termux/boot/start-tinyproxy.sh <<'EOF'
#!/data/data/com.termux/files/usr/bin/sh
termux-wake-lock
nohup tinyproxy -c $PREFIX/etc/tinyproxy.conf &
EOF
chmod +x $HOME/.termux/boot/start-tinyproxy.sh
ps -A | grep tinyproxy to confirm the daemon is active.pkill tinyproxy
termux-wake-unlockPort line in tinyproxy.conf to an unused number (e.g., 8899) and update the Android proxy settings accordingly.LogFile path points to a location you own. Use chmod 600 $HOME/tinyproxy.log if needed.curl as shown in Step 4.Allow CONNECT directive is present and that the Port you chose is not blocked by Android’s built‑in firewall (rare on modern versions).termux-wake-lock (Step 5) or enabling the “Battery optimization” exception for Termux (Settings > Apps > Termux > Battery > Unrestricted) solves this.Never expose Tinyproxy to the public internet by changing Listen 127.0.0.1 to 0.0.0.0 unless you add firewall rules and strong authentication. An open proxy can be abused for illicit traffic and may violate your carrier’s terms of service.
pkill tinyproxytermux-wake-unlockrm $PREFIX/etc/tinyproxy.conf ~/tinyproxy.logBy following this tutorial you now have a fully functional, locally‑bound HTTP/HTTPS proxy that runs entirely in user space. You can use it for:
User‑Agent strings by chaining Tinyproxy with sed or iptables tricks.The setup is lightweight, respects Android’s security model, and can be started or stopped with a single command. Because everything runs in Termux, you can also script more complex workflows (e.g., rotating logs, rotating proxy ports, or integrating with mitmproxy for deeper inspection).
Feel free to experiment with the configuration – Tinyproxy supports ACL files, upstream proxy chaining, and even basic caching. Just remember to keep the service confined to 127.0.0.1 unless you have a clear security plan.









