Using an iOS (iPad/iPhone) to access the webserver with virtual host on your computer

If you are doing web development and you want to debug your web application on an iPad it usually is not that hard to do. Just connect the iPad to the same WiFi your computer with the web server is running on and go to the LAN IP of that machine.

But what if your machine is using a webserver that is configured to use a virtual host? In that case, you can probably still connect to the IP directly but it will not always result in what you want. In this article I’m describing how to solve this issue. Best of all, this method is free.

After this article, you will be able to use any iOS device to connect to your webserver as if you would do it from the machine with the web server itself.


This should be your starting situation:

iPad or Android Device on the same network

Next we’re going to tell the mobile device (e.g. an iPad) to use the connection from your computer. There are several ways to do so, but I’ll use the most straight forward one: a SOCKS proxy.

For the next steps you need to have an active SSH server on your computer. I’m not going to explain that here as there are many good guides for that.

If you have an SSH server running:

  1. Configure your machine running the web server that it should allow SSH connections.
  2. Set up an SSH tunnel from the same machine you just created it on. Basically your SSH’ing to yourself. Do that using the following command:$ ssh -4 -g -D 1234 username@localhost -p 22Replace the username with something that works in your situation of course 🙂
  3. We just set up a tunnel! Now tell the iPad to use that tunnel.

Connecting an iOS device to a SOCKS Proxy tunnel

Unfortunately you can’t use a SOCKS Proxy out of the box when using an iPad (Apple, please fix that?). You have to do the following to use a SOCKS proxy on an iPad.

Create a file accessible for the iPad on your webserver with the following content and name it proxy.pac:

function FindProxyForURL(url, host) {
return "SOCKS";

Replace the IP with the IP of your machine that has Apache/nginx/any other webserver and SSH running on it. Don’t forget to put this file on your server, your iPad should be able to reach it.

Now for the iPad:

  1. Go to your WiFi settings.
  2. Select the connection you want to use (probably the one connected)
  3. You will arrive at the details page. At the bottom you can see the HTTP Proxy options.
  4. Select ‘Auto’. At the URL enter the location where the proxy.pac is.
  5. Re-enable the WiFi connection on the iPad again to activate these settings. Make sure that your SSH tunnel is running.

That’s all

Now you should have an iPad that can retrieve pages from your machine running the webserver the same as you could do it as from there.

Android is not covered here, but I guess this will be enough information to get you going with that as well!

Leave a Reply




Please proof you are human: * Time limit is exhausted. Please reload the CAPTCHA.