IPad – how to use ipad to access webserver on macbook air

ipadmacbook proNetworkweb appwebserver

my webserver software is nginx which runs very well on macbook air using mac os x 10.7.5

when i go to http://myapp.localhost on my macbook air, i can access my website perfectly which is running on localhost.

how can i access the website from my iPad? I am asking because i want to test if my website allows tablet to access just as well on desktop browsers.

i have two possible setups.

1) macbook air running HUAWEI-MOBILEModem and using INTERNET SHARING to allow the iPad to access.

2) when both macbook air and iPad are accessing the same WIFI connection.

Please provide solutions for both scenarios.

UPDATE:
i have more than 1 app running on my macbook air nginx webserver.

for conveniences, let's call them

etc.

How can my iPad access the correct webapp hosted on my macbook air?

UPDATE

on my macbook air, i access different webapps because i edited my /etc/hosts file.

Best Answer

In both scenarios, using the IP or machinename.local address of the Mac will only give you the default website on that Mac. Your web apps are all at the top-level so Nginx is expecting different hostnames in the request. Problem is, these hostnames end in .localhost which isn't being resolved by DNS, so the iPad doesn't know where myapp2.localhost is, and the request never reaches Nginx on the Mac.

You've already gotten around this problem somehow when testing from the Mac. Maybe you've edited the /etc/hosts file, or you have a GUI that does that? However, you can't modify the iPad hosts file without jailbreaking.

A simple workaround is to change the default website in Nginx to the webapp you want to test from the iPad - then you could use the machinename.local address from the iPad. But you have to change this every time you want to test a different webapp.

More complicated workarounds would be to a) configure Apache on the Mac as a proxy server, and configure the iPad browser to use that as its proxy; b) set up a DNS server on your local network; c) use instead the iPad simulator on the Mac, while modifying the /etc/hosts file; or d) jailbreak the iPad and modify /etc/hosts.