Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Android phone as wifi web server

I got this crazy idea that I don't know is possible or not... what I want to do is set up my phone as wifi access point, then allow people to connect to it, but handle all incoming http traffic myself.

So:

  • phone wifi in access point mode; open wifi network (this tidbit works - yes I know it's not officially supported but then I have no intention to distribute put this app on the open market or so, it works on my phone and that's good enough for me).

  • client can connect to the phone (e.g. my laptop: this also works).

  • when client tries to open an http connection to any random server, this has to be intercepted by my app and handled by a local web server. This is the point that I'm stuck on.

The web server part shouldn't be too hard; there are (open-source) web servers available. But getting the traffic to that web server, there is the problem.

The behaviour I'm after is a bit similar to what you get when connecting to some open hotspot, like hotel hotspots, that then redirect you to a login page. This intercepting of the connection request (I suspect I have to look at DNS requests?) is what I'm after.

I have seen an app that is doing this but they require the phone to be rooted. I'm hoping to find a way to do it without rooting the phone.

like image 892
Wouter Avatar asked Mar 18 '11 15:03

Wouter


People also ask

Can you run a server on a phone?

Per its name, FTPServer is a pretty simple and easy-to-use FTP server for your Android device. In order to set up a file server you need to configure it with your username and password of choice, set a default directory, and then connect with an FTP Client to begin adding and removing files of your choice.

Can mobile device act as server?

Yes, Bubble uPnP when running, effectively turns your phone into a DLNA media server.


1 Answers

Wifi hotspots would usually use IPTables to redirect port 80/443 traffic to a local web server.

I have run squid on linux machines in the past on port 3128, then sent all port 80/443 traffic to squid. Then I used squid redirect any url that I didnt explicitly allow to a local web server.

IPTables is accessible on rooted android devices only though.

And I doubt there are many proxy servers available on android, so you would have to send HTTP traffic to a proxy server over the network connection.

like image 58
GarethAyres Avatar answered Nov 15 '22 01:11

GarethAyres