Should iOS Universal Links work over custom ports? - ios

I am trying to get iOS Universal Links to work for https://my-domain.com:4443 (i.e. over SSL, but with a custom port number; not the conventional 443 port), but it isn't working.
I'm pretty confident I didn't do anything wrong, since my initial setup worked fine over port 443, and I simply changed the server port to 4443 to test the idea. In fact, I also added support for applinks:my-domain.com:4443 in my Xcode project (I tried both with and without the port, without any luck).
I am asking the question, because I couldn't find anything on the subject in the official documentation.

This is expected behavior. There is nothing in the official documentation about supporting non-standard ports because non-standard ports aren't supported.
The only entitlement value allowed by iOS is a valid, bare domain (applinks:my-domain.com), which iOS will then use to check for an AASA file over SSL using the standard HTTPS port. In other words, when iOS queries either https://my-domain.com/apple-app-site-association or https://my-domain.com/.well-known/apple-app-site-association, it needs to find your AASA file without any redirects.

Related

PAC FILE - Not being loaded

I am new to pac files. I am not sure I made it working.
I installed an nginx on a virtual machine. and exposed a pac file to url.
(I can easily download pac file by puting url in browser as proof it is working).
I then set my computer proxy settings as explained in many guides. I ticked the automatic proxy settings and I then put pac file url.
After that I think the file is not being loaded.
puting : "chrome://net-internals/#proxy" gives an empty list while it should show the pac file. Plus the net seems to work as the pac is not even there.
For further information, since I am new to pac file, I am just testing a simple pac file which redirect ALL traffic to youtube.com.
can anyone help me out?
Thanks
function FindProxyForURL(url, host) {
return "youtube.com";
The format to return is something like return "PROXY youtube.com:80". However I do not think this will work, as Youtube is not a proxy.
PAC files must return a Proxy. But Youtube is just a site, which is something completely different than a Proxy.
PAC files are unable to replace a Proxy. All they do is to point to the proxy to use when you want to reach some specific URL. This way you can configure how to reach certain networks, like some Extranet (via some dedicated HTTP proxy or TOR or I2P (via SOCKS proxies). This is why you also must specify the type of the Proxy used and the port number where the Proxy sits. Just a name usually is not enough.
Also note that you can give more than just one Proxy. For more information on PAC-files see the main documentation:
https://developer.mozilla.org/en-US/docs/Web/HTTP/Proxy_servers_and_tunneling/Proxy_Auto-Configuration_(PAC)_file
(Sorry for the link, but if a Link to MDN ever breaks, the Net probably has some bigger trouble than just this broken link.)

Is it possible to share my localhost with someone on a different network?

I am working with a designer and I'd like them to have access to the interactions I've implemented on the site we're working on. However this time, I have 2 issues. My localhost is configured to a subdomain:
http://store.teststore:3000/ and we're on different networks. Is there anyway to work around this?
ngrok should work for you. Download and install it following these instructions here: https://ngrok.com/download. Documentation on how it is used can be found here https://ngrok.com/docs. Once installed running the below command should work for you (depending on the hosting environment):
ngrok http -host-header=rewrite store.teststore:3000
You will need to give the URL generated by ngrok and displayed in the cmd prompt to the designer.
Update: Handling absolute redirects
Based on your comment it sounds like, after login, your site does an absolute redirect (the full URL is specified). If it is possible I would change your code to do a relative redirect where the domain is omitted. You could also make your root domain configurable in the absolute redirect and configure it to be the ngrok domain provided for now. Lastly, you could attempt to configure your DNS with a CNAME record following ngroks Tunnels to custom domains documentation. This last option, however, requires a paid for ngrok subscription.
Install ngrok if you haven't yet and CD into your project directory and invoke ngrok. Note Your application must be running locally on the same port number ngrok will be running.

Intern test framework hangs/does nothing when used with Appium 1.4.13 on an iOS device for mobile web

I just started looking into using the intern test framework to write functional tests for our mobile web apps. I'm looking to run these tests on actual iOS devices.
I setup Appium as the selenium server talking to the intern client. It works as expected on the simulator (although I get 'method not implemented' for many of the touch related methods).
I then decided to configure everything to work on my iPhone 6 plus, running iOS 9.0.2
After much wrangling with instructions from here, I got all the various pieces working in tandem (ios-webkit-debug-proxy, appium-server from the repo, etc.)
Finally, I decided to run my tests. When I run the test runner, Safari on my device starts up (via SafariLauncher App), and ios-webkit-debug-proxy and appium-server seem to be talking to each other. However, intern simply posts a 'created session on...' message, and then does nothing.
To ensure that the server was running properly, I decided to use a rest client to send it POST and GET requests using the JSONWire Protocol methods, and it seems to be loading the web-page url and responding to JSONWire requests. So clearly, something is going wrong with Appium talking to intern, or vice-versa.
Any help/insight on this would be greatly appreciated. Thanks!
I'm also in the unique position of having to run these locally, so using SauceLabs, BrowserStack, etc. is out of the question.
Got it working!!!
So the trick was to specify the proxyUrl config option.
My original conjecture was that there might have been some issues with basePath, etc., but I noticed my console.log statements that were outside of test cases were running properly.
That's when I noticed that the Safari page tried to navigate to localhost right after the test had started. This is my first time ever working with Intern or Appium or any Selenium stuff for that matter. Because you cannot access localhost (which in this case was meant for accessing the Intern server on my computer, since you're running the tests on your computer, and not on an external device), from the iPhone, I specified proxyUrl and proxyPort in the config, and specified my computer's local IP (192.168.x.x) and the Intern server port (9000). It still didn't work. I looked at the URL in Safari and noticed that it wasn't using the proxyPort field - so that the URL looked like: 192.168.x.x/__intern/clie... So I just tried to enter the port in the proxyUrl option - as that option's a string - 192.168.x.x:9000. And voila - it worked!!!
So hopefully this helps some other soul looking to have a native mobile test working with this setup!

My rack-proxy app works with different ports, but not different URLs

I wrote a little Rack app the uses rack-proxy to make it look like apps that are running on different ports are actually different subdirectories of one domain. It works.
If I'm running notes on port 3001 and photos on 3002, then I'm able to go to localhost:3000/notes or localhost:3000/photos and everything works properly.
That's only helpful for running it locally. But if I want to run this same setup on Heroku I need to be able to proxy to/from different URLs, not just different ports. So when I change my code from setting env["HTTP_HOST"] to http://localhost:3001 for /notes, to instead set env["HTTP_HOST"] to http://sbbme-note.herokuapp.com for /notes, Rack blows up on me.
I thought it would Just Work™. Unfortuntely, I'm missing something.
Errno::EADDRNOTAVAIL at /notes
Can't assign requested address - connect(2) for "http://sbbme-note.herokuapp.com" port 0
The full stack trace is in this gist.
https://gist.github.com/veganstraightedge/6d840377bf20b4b5f5db
The repo is homesteading/homesteading-router-rack. The master branch is the one working in local development mode only (multiple ports on localhost). The heroku-router branch is where I'm trying to use different (sub)domains instead of just different ports. heroku-router is the one that blows up (see gist above).
If you want to install this and try it on your own machine, this should work:
gem install homesteading
homesteading new mysite
cd mysite
homesteading server
open http://localhost:3000
I'm real close to being able to replace my years old pile of mono-rails with my constellation of apps approach in Homesteading. This router is the last main blocker. Any help would be greatly appreciated.
PS. My intial version is based on this blog post (livsey dot org/blog/2012/02/23/using-rack-proxy-to-serve-multiple-rails-apps-from-the-same-domain-and-port) and this Stack Overflow question/answer (stackoverflow dot com/questions/11057905/how-do-i-use-rackproxy-within-rails-to-proxy-requests-to-a-specific-path-to-an "How do I use Rack::Proxy within Rails to proxy requests to a specific path to another app - Stack Overflow").
Looking at the setup and the stack trace it looks like the proxy is atrying to connect to the sbbme-note app on port 0. Try adding
ENV['SERVER_PORT'] = '80'
You might also consider using the nginx build pack on heroku an implementing a forward proxy that way. I've used this build pack as a basic forward proxy and it has worked great. There are other nginx build packs that are designed to hook up to you application server (like unicorn) that might also be useful for this use.
The solution was a combination of Lukas' suggestion and fixing what I was originally doing.
I added this (as suggested by Lukas).
env['SERVER_PORT'] = 80
AND I removed the http:// from my env["HTTP_HOST"]
So, this:
env["HTTP_HOST"] = "http://#{app}"
became this:
env["HTTP_HOST"] = app
Thanks for your help, Lukas!

Can I edit an iPad's host file?

I doubt this is possible without extensive jail-breaking, but is it at all possible to edit the iPad's (or any iOS device's) hosts file?
The previous answer is correct, but if the effect you are looking for is to redirect HTTP traffic for a domain to another IP there is a way.
Since it technically is not answering your question, I have asked and answered the question here:
How can I redirect HTTP requests made from an iPad?
No, you can't change iPad's host file(without jailbreak), but can workaround.
Here is my scenario:
Mac OS X, with IP 192.168.2.1, running a web app
iPad, the device you would like to test the web app
Charles (for Mac), enables HTTP proxy for your iPad
I am going to test the web app running in my Mac via iPad, but I can't access directly to it.
The solution works for me:
Firstly, make sure that your server and iPad are in the same local network.
Then, set up Charles proxy, in the menu "Proxy > Proxy Settings...", fill in Port(mostly 8888) and toggle Enable transparent HTTP proxying.
Setup proxy setting in iPad.
Now you can visit your web app in iPad.
Of course you can use other proxy tools like Squid or Varnish in Linux, or fiddler in Wondows.
No. Apps can only modify files within the documents directory, within their own sandbox. This is for security, and ease of installing/uninstalling. So you could only do this on a jailbroken device.
The easiest way to do this is to run an iPad simulator using XCode and then add an entry in the hosts file (/etc/hosts) on the host system to point to your test site.
I needed the same functionality, and doing jailbreak is no-no. One solution is to host yourself DNS server (MaraDNS), go to your wifi settings in ipad/phone, and add your custom DNS server there.
The whole process took me only 10 minutes, and it works!
1) Download MaraDNS
2) Run mkSecretTxt.exe as administrator
3) Modify mararc file, mine is:
ipv4_bind_addresses = "put your public IP Here"
timestamp_type = 2
random_seed_file = "secret.txt"
csv2 = {}
csv2["Simple.Example.com."] = "example.configuration"
Add file called "example.configuration" into the same folder where run_maradns.bat is.
4) Edit your example.configuration file:
Simple.Example.com. 10.10.13.13 ~
5) Disable all Firewalls (convenience)
6) Run file "run_maradns.bat"
7) There should be no errors.
8) Add your DNS server to list, as shown here: http://www.iphonehacks.com/2014/08/change-dns-iphone-ipad.html
9) Works!
Yes, you can edit the iPad hosts file, but you need to be jailbroken. Once you've done that, download Cydia (app market), and get iFile. The hosts file is located within "/etc/hosts".
I would imagine you could do it by setting up a transparent proxy, using something like charles and re-direct traffic that way
Workarond I use for development purposes:
Create your own proxy server (One option would be: Squid on Linux).
Set your hosts file with your domains.
Set the proxy server on the IPAD/IPHONE and you can use with your hosts.
I know it's been a while this has been posted, but with iOS 7.1, a few things have changed.
So far, if you are developing an App, you MUST have a valid SSL certificate recognized by Apple, otherwise you will get an error message on you iDevice. No more self-signed certificates. See here a list:
http://support.apple.com/kb/ht5012
Additionally, if you are here, it means that you are trying to make you iDevice resolve a name (to your https server), on a test or development environment.
Instead of using squid, which is a great application, you could simply run a very basic DNS server like dnsmasq. It will use your hosts file as a first line of name resolution, so, you can basically fool your iDevice there, saying that www.blah.com is 192.168.10.10.
The configuration file is as simple as 3 to 4 lines, and you can even configure its internal DHCP server if you want.
Here is mine:
listen-address=192.168.10.35
domain-needed
bogus-priv
no-dhcp-interface=eth0
local=/localnet/
Of course you have to configure networking on your iDevice to use that DNS (192.168.10.35 in my case), or just start using DHCP from that server anyway, after properly configured.
Additionally, if dnsmasq cannot resolve the name internally, it uses your regular DNS server (like 8.8.8.8) to resolve it for you. VERY simple, elegant, and solved my problems with iDevice App installation in-house.
By the way, solves many name resolution problems with regular macs (OS X) as well.
Now, my rant: bloody Apple. Making a device safe should not include castrating the operating system or the developers.
If you have the freedom to choose the hostname, then you can just add your host to a dynanmic DNS service, like dyndns.org. Then you can rely on the iPad's normal resolution mechanisms to resolve the address.
You can also make use of a proxy server on your iPhone or iPade via mobile internet (3G) by using a iPhone Mobile proxy generator:
http://iphonesettings.net/mobileproxygenerator.php
Just enter the apn of your carrier (with apn username/password if needed) and the proxy server you want to go through and tap Generate
Problem Restated: Bypassing DNS Resolution
The problem the OP is trying to solve is NOT hacking hosts files on iPads per se, but rather bypassing DNS Resolution of a specific published DNS record by creating a static, local IP:name mapping on their device.
Solution:
A better- and more scalable- way is to create the static IP:Name mapping that you'd create in the hosts file on the device and instead create it on the router and then point your DHCP addressed clients to that router as the primary source of DNS resolution as I document (with annotated screen shots) HERE.
Conclusion:
When testing a new site you need to check the display of it on multiple devices to ensure there's no funky display or usability issues. Bypassing DNS checking using static local IP:Name mappings would require each developer to hack the hosts files for each of their devices and then remember to unwind the changes in all their devices after testing.
And were it even possible to hack an iPad's hosts file as the OP enquired about, in many organizations the Developers IT assets will be locked-down and they won't they have administrative permissions to do such tinkering.
Better to make the static mapping to bypass the published DNS record in the router and then you can delete it in one place after testing is completed.
You need access to /private/etc/ so, no. you cant.
Best Answer: Simply add http or https in your browser, the IP address, colon and port number. Example: https://123.23.145.67:80

Resources