1

I want to access a website and an API both running in Docker containers behind another nginx Docker container (reverse proxy managing SSL) from an iOS device.

So I have:
1 iOS device having IP 192.168.178.57
1 MacBook Pro having IP 192.168.178.64
1 Docker container running nginx having two server_name settings: app.dev and api.dev, both using self-signed SSL certificates /etc/hosts points has these entries:

192.168.178.64 app.dev
192.168.178.64 api.dev

~/proxy.pac contains these entries:

function FindProxyForURL(url, host){
  if (shExpMatch(host, "app.dev")) {
    return "PROXY app.dev:443; DIRECT";
  }
  if (shExpMatch(host, "api.dev")) {
    return "PROXY api.dev:443; DIRECT";
  }
  return "DIRECT";
}

Squidman is configured on port 9090 and allowed clients are 192.168.178.0/24.

Squidman template allows access to localhost

# protect web apps running on the proxy host from external users
# http_access deny to_localhost

# rules for client access go here
http_access allow localhost
%HTTPACCESSALLOWED%

The iOS device proxy is configured as 192.168.178.64, port 9090.

The MacBooks Networks Automatic Proxy Configuration points to the ~/proxy.pac file.

I can browse web sites from the iOS website like http://apple.com.

I can browse https://app.dev and call https://api.dev from the MacBook.

I cannot browse https://app.dev nor call https://api.dev from the iOS device.

What am I doing wrong?

4
  • Tried this already with /etc/hosts but using /private/etc/hosts/ didn't fix it neither. Mar 18, 2017 at 19:30
  • I'm gonna set it up in a virtual environment to comprehend your problem
    – klanomath
    Mar 18, 2017 at 19:32
  • Do you have a quick setup guide (or other instructions) to install the reverse proxy (SSL) docker image (which one did you use?) and the other two nginx docker images?
    – klanomath
    Mar 18, 2017 at 21:53
  • Check out xip.io next time - often far easier to just use FQDN for all the non-routable IP you need for proxies, containers, VM and devices to test.
    – bmike
    Apr 23, 2017 at 20:58

2 Answers 2

1

I solved it using this Docker container: https://github.com/jpillora/docker-dnsmasq

Simply follow the instructions and add e.g. 127.0.0.1 app.dev and 127.0.0.1 api.dev to your /etc/hosts.

Then change the DNS on the macOS and iOS device to 192.168.178.64 (following the initial question).

0

[on hold (the answer is right under certain circumstances but sometimes wrong) - under construction]

iOS has no clue where and what api.dev and app.dev are. The entries in the hosts file are valid for the local host only.

Since you can't modify iOS' hosts file without jailbreaking the iOS device you have to set up a DNS-server (e.g. brew + dnsmasq) on your MacBook Pro and point iOS' DNS setting to it.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .