how to use ipad to access webserver on macbook air

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

  • http://myapp1.localhost
  • http://myapp2.localhost

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.


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.


localhost is device-specific, so visiting it on your iPad is is taking you to a page on your iPad itself (that probably doesn't exist).

To access a page that is served from your Mac from your iPad, use the Mac's local IP address instead of localhost. To get your Mac's local IP, open the Network pane of System Preferences. Select your active network on the left and the IP will be shown on the right under the Connected heading. It will probably be something that looks like 10.0.1.1 or 127.0.1.1.


You can try to enter your Mac's hostname followed with a .local.

So if the name of your computer is epsilon.

    http://epsilon.local

As stated by Nathan the ip address would work. Replace my example IP with your actual IP.

    http://192.168.1.1

You would add your specific app information at the end of these addresses. So what ever comes after the http://localhost would be appended to the end of these URLs.