I somehow want to access to my developing websites locally from my smartphone so investigated and wrote a memo.
Once access to local network, I can access to the website from my iPodTouch by typing ip address indicate my mac.
However iOS doesn’t rewrite hosts file, so it doesn’t access the websites over the reverse proxy, it means Nginx, working on the mac.
First, I thought to solve the problem by BIND, but more easy way was detected.
As Mac, use DNSMASQ.
This is available to resolve name from the /etc/hosts file so it’s convenient.
In my case, install it from homebrew.
sudo brew install dnsmasq touch /usr/local/etc/dnsmasq.conf sudo ln -s /usr/local/etc/dnsmasq.conf /etc/dnsmasq.conf
In any point of the above sequence, you may ask the question DNS port open or not, then you have to toggle yes.
#symlink of /etc is my favorite
write the below to /etc/dnsmasq.conf(/usr/local/etc/dnsmasq.conf)
port=53 domain-needed bogus-priv expand-hosts local=/axtstar.com/ log-queries log-facility=local0
/etc/hosts was like the below
xx.xxx.xx.xxx en.axtstar.mymac
Previously check your mac IP address by ifconfig or something.
en.axtstar.mymac is the DOMAIN you should resolve.
So your iphone access to private webserver by safari(Of course, you have to change the DNS address on your iphone. see the next.)
Developing, almost hosts files are somehow like the below 127.0.0.1 en.axtstar.local However even if 127.0.0.1 change actual address indicate your mac, it doesn't work from mac/iphone. ".local" seems a system preserved name. Android also partly didn't work.
The last things to do is start DNS server.
#start sudo brew services start dnsmasq #stop sudo brew services stop dnsmasq #restart sudo brew services restart dnsmasq