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.

iPad

This should be your starting situation:

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:

Configure your machine running the web server that it should allow SSH connections.

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 🙂

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:

About

Welcome to my blog! My name is Sander Thalen and I am a Frontend Developer. On this blog I'll publish articles on a very irregular basis on a variety of subjects. Feel free to post your comments, feedback and questions, they are appreciated!