How can I redirect HTTP requests made from an iPad?

ios http request
swift 5 http request
ios http request objective-c
nsurlrequest
ios urlrequest
urlsession
swift asynchronous http request
https request swift

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

The way to get around this limitation of the iPad is to use a HTTP proxy server, such as Squid running on another machine where you can edit the hosts file.

On the iPad Under Settings -> Network -> Wi-Fi -> (Your network) There is a HTTP Proxy setting which can be set to manual. Enter you proxy information here.

Once this is set up you would be able to manipulate the iPad as if you were changing the hosts file.

How can I redirect HTTP requests made from an iPad?, The way to get around this limitation of the iPad is to use a HTTP proxy server, such as Squid running on another machine where you can edit the hosts file. On the iPad Under Settings -> Network -> Wi-Fi -> (Your network) There is a HTTP Proxy setting which can be set to manual. Enter you proxy information here. Once this is set up you would be able to manipulate the iPad as if you were changing the hosts file.

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.

Making HTTP and HTTPS Requests, for making HTTP and HTTPS requests. With these APIs, you can download files to disk, make simple HTTP and HTTPS requests, or precisely  When choosing an API, you should first consider why you are making an HTTP request: If you are writing a Newsstand app, you should use the NKAssetDownload API to download content in the background. If you need to download a file to disk in OS X, the easiest way is to use the NSURLDownload class.

Setup the hosts file on a computer running a proxy server such as Fiddler or Charles, and configure the iPad to use that computer as an HTTP proxy.

Here are instructions for how to do this with Fiddler: http://conceptdev.blogspot.com/2009/01/monitoring-iphone-web-traffic-with.html

And this is for Charles: http://www.ravelrumba.com/blog/ipad-http-debugging/

Does iOS11 not block redirect to h…, I currently have the issue that I have an https-request, that redirects to an http-​URL. It's hard to make any concrete assertions about that without knowing the  Note: If you created a new HTTP listener following steps 3-5 above, skip to Create an HTTPS listener. Select a load balancer, and then choose HTTP Listener. Under Rules, choose View/edit rules. Choose Edit Rule to modify the existing default rule to redirect all HTTP requests to HTTPS. Or, insert a rule between the existing rules (if

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.

sudo apt-get install libapache2-mod-proxy-html
sudo a2enmod proxy proxy_http proxy_html
sudo apache2ctl graceful

Then create a virtual host file, for example /etc/apache2/sites-available/my-proxy

Listen *:8080
<VirtualHost *:8080>
    ProxyRequests On

    <Proxy *>
        Order Deny,Allow
        Deny from all
        Allow from 192.168.1.0/24 
    </Proxy>
</VirtualHost>

Enable the vhost, and restart Apache:

sudo a2ensite my-proxy
sudo apache2ctl graceful

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

Preventing Insecure Network Connections, It does this by requiring that network connections made by your app are secured App Transport Security has blocked a cleartext HTTP (http://) resource load since it The link must support perfect forward secrecy (PFS) through Elliptic Curve  sur l'iPad sous Paramètres -> Network -> Wi-Fi -> (votre réseau) il y a un paramètre de mandataire HTTP qui peut être défini en mode manuel. Entrez les informations de votre mandataire ici. une fois que cela est configuré, vous serez en mesure de manipuler l'iPad comme si vous changiez le fichier hosts.

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.

<VirtualHost *:80>
  ServerName sapphire.local
  ProxyPass / http://demo.cms.dev/
  ProxyPassReverse / http://demo.cms.dev/
  ProxyPassReverseCookieDomain .cms.dev .sapphire.local
  ProxyPreserveHost Off
</VirtualHost>

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?

NSURLSession, of which represents a request for a specific URL (following HTTP redirects, Transport Security (ATS) for all HTTP connections made with NSURLSession . Instead of dropping the request, you might want to redirect the request to a secure web site. You can use the responder feature to redirect the request to the secure web site without changing the path and the URL query which the user attempts to access. How Citrix ADC responder redirects a request from HTTP to HTTPS. The following illustration

Beginning iPhone and iPad Web Apps: Scripting with HTML5, CSS3, , 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  Use a redirect service. The simplest option to perform an HTTPS redirect is to use a redirection service. DNSimple provides a redirector service you can use to redirect HTTPS requests. Using a service is the simplest solution, because it requires little configuration and almost no technical knowledge.

Professional iOS Network Programming: Connecting the Enterprise to , Note that redirection (for instance, codes 301 or 302) is automatically handled, so you will Once these verifications have been made, you will want to gather the data Gathering data through an HTTP request, especially on mobile devices,  Redirect using HTTP Redirect on windows 2008 R2 The redirect in windows 2008 R2 is very simple; open IIS and select the default website or chose a specific website if you have many websites. Once you have made your choice, double click on “HttpRedirect”( figure1 ), check this option “ Redirect requests to this destination” then enter

Internet Security You Can Afford, Connecting the Enterprise to the iPhone and iPad Jack Cox, Nathan Jones, This URL may differ from the URL provided in the request due to redirects or normalization. NSHTTPURLResponse that contains properties specific to HTTP requests. When a synchronous request is made, the thread on which the request is  HTML redirections. HTTP redirects are the best way to create redirections, but sometimes you don't have control over the server. In that case, try a <meta> element with its http-equiv attribute set to Refresh in the <head> of the page. When displaying the page, the browser will go to the indicated URL.

Comments
  • Just for the record I'd say that is pretty easy to install squid using macports "sudo port install squid"
  • or yum install squid on fedora
  • or apt-get install squid on Ubuntu
  • Note: each time you edit the hosts file on your Squid server, restart the Squid service to be sure the edits take effect. On Ubuntu that's sudo service squid3 reload. Also--and maybe this is a config problem specific to my dev server--on my iPad I have to manually enter the http:// for address resolution to work correctly.
  • Another, easier way to do this is with a tool I wrote: testProxy. No configuration necessary: github.com/edwinm/testProxy
  • Great answer. If you're testing a rails app using Webrick, just set the ip address of your dev machine and port 3000
  • If you're using Wamp or uWamp on Windows, set the port to 80.
  • What about cases like mine where your local app pulls data from various API's on the net?
  • Thanks for fleshing out the Windows/Mac options.
  • For us Windows developers, Fiddler is a great option, since most developers already have it installed.
  • This pointed me in the right direction. Initially, I got an error message "No protocol handler was valid for the URL". I found I had to load both proxy_module and proxy_http_module to get it to work. Thanks!
  • Thanks. I just purchased this and am going to try it out.