Since on an iPad we cannot edit the hosts file (without jailbreaking), how can we arbitrarily redirect web traffic to another url?
This would be important for something such as developing a website that uses a Virtual Host configuration where you want to redirect to a development machine.
(This is related to this question: Can I edit an iPad's host file?)
I made it by using squidman on Mac. It's easy to set up and use.
I set it up in 5 minutes by following this article.
Update
Another thing is if you want to connect to the websites running on proxy server, in my case it's my Mac, you need to comment this line out in squidman->Preferences->Template
If you have a live website you can use for this:
You can add an A record to your DNS configuration: something.yourdomain.com which points to your local IP address, then add an entry for something.yourdomain.com to your virtual hosts file. Restart Apache, get your iOS device on the same network and you're good to go.
I need to test web apps I am developing on an iPad. I use Apache on my dev machine to run the web apps, so the easiest solution I found was to use Apache mod_proxy.
My dev machine is visible on my home network as sapphire.local.
The web app I am testing is at hosted on the dev machine at demo.cms.dev (I am using POW).
To setup the proxy, I added the following section to httpd.conf.
This routes incoming requests on sapphire.local to demo.cms.dev. The method only works for one app at a time. I think you could use different ports to setup additional apps. Maybe someone has a better solution?
You could setup an internal DNS server on your network (if one does not exist already) and setup an A record. Then ensure your DHCP is set to return said DNS server
I found you just have to modify the Wifi settings in your iPad to use the IP address of your development machine as an HTTP proxy (as explained in the aforementioned article):
That way, it's enough to be able to access your web application on your iPad by entering the url of the virtual host (e.g.
local.mywebapp.com
). It's easy and quick, but unlike Will Koehler's solution, you will however not be able to access Internet from the iPad. But most of the time it's not really a problem, since you just want to test your own application.If you already have an Apache server where you're doing dev, you can easily use it as a forward proxy. This is particularly useful for WordPress sites, which really love to use the full absolute URL.
Ubuntu example below:
The first step is to edit the
/etc/hosts
file in your dev server. Add the server's local IP, pointing to your site.127.0.0.1 dev.mysite.com
This hosts file will be used by your Apache proxy when it tries to resolve requests from your iPhone / iPad. So let's setup the Apache part now...
You may need to install some modules first.
Then create a virtual host file, for example
/etc/apache2/sites-available/my-proxy
Enable the vhost, and restart Apache:
Then go to Settings > Wi-Fi > Your Network and configure a "Manual" proxy. Enter the IP of your Apache server, and the port. That's it!
The
<Proxy *>
block ensures that only people on my local network can use this proxy. Strictly limiting access is essential if you are using a forward proxy. The ip2cidr page will be helpful at this point. (As an extra measure, the :8080 port is blocked by my firewall.)