How can I redirect HTTP requests made from an iPad

2019-01-20 22:01发布

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?)

16条回答
何必那么认真
2楼-- · 2019-01-20 22:51

Here is a no configuration method for cross device/computer testing of a Mamp Pro Virtual host. The only limitation is you can only test one domain at a time, but for me this is fine when I'm developing. It is really simple however to change between virtual hosts directly in mamp.

Im running mamp pro 2, mountain lion. My sites folder contains the individual domain folders.

I found if you choose the specific ip of the local computer under the virtual host 'ip /port' and restart mamp this domain will become the default domain when viewing the localhost computers' ip address, or computer name, across the network.

For testing purposes this works great across all devices on the network, including the iPad. If you want to test another virtual host you can simply return the ip/port config to "*" and then reassign another domain to the computers ip address and restart.

The advantage of this simple approach is you can provide access to clients directly to your development sites when your on the same network without having to go through any configuration on their machine.

Hope this helps anyone else looking for simple solution.

查看更多
何必那么认真
3楼-- · 2019-01-20 22:53

If you've been exploring this, and a few of the external links, you will possibly find this answer:

https://stackoverflow.com/a/24770097/3842985

It is about a light-weigh DNS server called dnsmasq. Super simple, very powerful, and can be used in conjunction with your internal or external DNS servers.

Much easier than installing squid, fiddling with Apache, and other techniques that would be time-consuming, and risk the "integrity" of configurations, develop environments, test environments, etc.

Well worth considering.

I adopted that as a regular tool for development and for normal networking.

查看更多
beautiful°
4楼-- · 2019-01-20 22:54

Answers herein are correct. A bit more knowledge: These will not work with cert pinning. What you can do is either (1) use a domain wildcard cert to support your dev/test/qa region testing. And/or (2) use a reverse proxy server such as Apache whereby you change to where Apache routes the requests within your network. Now, when you get into SSL Pinning testing then you are dead in the water with the physical devices and can only validate with simulator (ios) and emulator (android).

查看更多
我想做一个坏孩纸
5楼-- · 2019-01-20 22:55

You can also use http://xip.io/ using the instructions on that page you can enter the ip address and it will redirect you to the relevant local ip.

查看更多
登录 后发表回答