A distributed web hosting solution that allows Android devices to serve websites directly, with automatic IP address management and reverse proxy configuration.
Phone Site consists of two main components:
- Android App - An HTTP server application that runs on Android devices to serve websites
- Server Scripts - Python scripts for managing device IP addresses and updating reverse proxy configurations
The system enables Android devices to act as web servers, automatically registering their IPv6 addresses with a central server that updates Nginx reverse proxy configurations in real-time.
- Embedded HTTP Server: Runs a lightweight HTTP server on port 5000
- Customizable Content: Edit and serve custom HTML content directly from the device
- Automatic IP Registration: Periodically pings a central server with the device's IPv6 address
- RESTful API: Provides endpoints for serving content and handling messages
- Simple UI: Easy-to-use interface for starting/stopping the server and editing content
- IP Manager: Flask server that receives device pings and manages IPv6 address mappings
- Nginx Integration: Automatically updates Nginx configuration files when device IPs change
- Load Testing: Utility script for testing server performance
phone-site/
├── PhoneSite/ # Android application
│ ├── app/
│ │ ├── src/main/
│ │ │ ├── java/app/phonesite/manager/
│ │ │ │ ├── MainActivity.kt # Main application activity
│ │ │ │ └── webserver/
│ │ │ │ └── WebServer.kt # Web server implementation (commented out)
│ │ │ ├── res/ # Android resources
│ │ │ └── AndroidManifest.xml
│ │ └── build.gradle
│ └── build.gradle
└── ServerScripts/ # Python server scripts
├── ipmanager.py # IP address management server
└── load_test.py # Load testing utility
- Minimum SDK: 21 (Android 5.0 Lollipop)
- Target SDK: 33 (Android 13)
- Kotlin: 1.7.20
- Gradle: 7.3.1
- Android Gradle Plugin: 7.3.1
- Python 3.x
- Flask (for
ipmanager.py) - aiohttp (for
load_test.py) - Nginx (for reverse proxy configuration)
-
Clone the repository
git clone <repository-url> cd phone-site/PhoneSite
-
Open in Android Studio
- Open Android Studio
- Select "Open an Existing Project"
- Navigate to the
PhoneSitedirectory
-
Build the project
./gradlew build
-
Install on device
./gradlew installDebug
-
Permissions
- The app requires
INTERNETpermission (already configured inAndroidManifest.xml) - Ensure the device has IPv6 connectivity
- The app requires
-
Install Python dependencies
pip install flask aiohttp
-
Configure Nginx
- Ensure Nginx is installed and configured
- Update the
nginx_config_pathinipmanager.pyto match your Nginx configuration directory - The script expects Nginx configs in
/etc/nginx/sites-available/
-
Run the IP Manager server
cd ServerScripts python ipmanager.pyThe server will run on
[::]:999(IPv6, port 999) -
Configure the Android app
- Update the server URL in
MainActivity.kt(line 193) to match your server's address:
val serverAddress = URL("http://[YOUR_SERVER_IPV6]:999/ping")
- Update the server URL in
-
Start the Server
- Launch the app on your Android device
- Tap "Start Server"
- Enter the website URL/name when prompted
- The server will start on port 5000
-
Edit Website Content
- Tap the "EDIT" button
- Modify the HTML content in the dialog
- Save changes
-
Stop the Server
- Tap "Stop Server" to shut down the HTTP server
The Android app exposes the following endpoints:
GET /orGET /index- Returns the configured HTML contentGET /messages- Returns all messages (placeholder implementation)POST /messages- Accepts JSON message data (placeholder implementation)
IP Manager (ipmanager.py)
- Listens for ping requests from Android devices
- Tracks IPv6 addresses per website
- Updates Nginx configuration when IPs change
- Automatically reloads Nginx
Load Test (load_test.py)
- Sends multiple concurrent requests to a target URL
- Useful for testing server performance
- Configure target URL and number of requests in the script
Default Content: The app includes a default "Techverse Conference" landing page. You can edit this through the UI or modify the TECH_VERSE_LANDING_PAGE variable in MainActivity.kt.
Ping Interval: Currently set to 10 seconds (configurable in MainActivity.kt, line 37).
Server Port: Default port is 5000 (configurable in MainActivity.kt, line 44).
IP Manager Configuration:
- Update
nginx_config_pathto match your Nginx configuration directory - Modify the IPv6 address pattern matching if your Nginx config format differs
- Ensure the script has appropriate permissions to modify Nginx configs and reload the service
cd PhoneSite
./gradlew assembleDebug# Unit tests
./gradlew test
# Instrumented tests
./gradlew connectedAndroidTest┌─────────────────┐ ┌──────────────────┐ ┌─────────────┐
│ Android Device │─────────▶│ IP Manager │─────────▶│ Nginx │
│ (HTTP Server) │ Ping │ (Flask Server) │ Config │ (Reverse │
│ Port: 5000 │ Every │ Port: 999 │ Update │ Proxy) │
└─────────────────┘ 10s └──────────────────┘ └─────────────┘
│
│ Serves HTML
▼
┌─────────────────┐
│ Web Clients │
└─────────────────┘
- The
WebServer.ktfile is currently commented out; the server functionality is implemented directly inMainActivity.kt - The app uses cleartext HTTP traffic (configured in
AndroidManifest.xml) - IPv6 connectivity is required for the IP registration system to work
- The message handling endpoints (
/messages) are placeholder implementations
[Add your license here]
[Add contribution guidelines here]
[Add author information here]