How to access vhosts via IPad?

2.1k Views Asked by At

I'm using XAMPP, on Mavericks, to simulate a localhost. I set jobeet.local, for example, as my vhosts. I tried to access it on my computer, it worked as well.

Now, I want to test my website on an IPad. So, I did the following steps:

  1. Run XAMPP server on port 80, as usual
  2. Connect the IPad to my wifi network.
  3. Setup Http Proxy on Ipad, as picture showed below but change the port to 80

enter image description here

Now, I tested to access 127.0.0.1 via IPad. It worked! However, jobeet.local doesn't work.

I have searched and tried many ways to achieve this issue but they don't work. Could you help me figure it out? Thanks in advance.

4

There are 4 best solutions below

2
On

You might have to update the hosts file.

The hosts file is a text file that maps hostnames to IP addresses. Upon typing a url address on the browser, the system is checking if there is a relevant entry on the hosts file and gets the corresponding IP address, else it resolves the IP via the active connection’s DNS servers.

The hosts file can be edited to block certain hostnames (like ad-serving/malicious hosts), or used for web development purposes, i.e. to redirect domains to local addresses.

Editing the hosts file

Editing the hosts file in Mac OS X – Leopard, is a pretty easy task, especially if you are familiar with the terminal.

Step 1 – Open the Terminal.app

Either by start typing Terminal on the Spotlight, or by going into Applications -> Utilities -> Terminal.

Step 2 – Open the hosts file

Open the hosts by typing on the Terminal that you have just opened:

$ sudo nano /private/etc/hosts

Type your user password when prompted.

Step 3 – Edit the hosts file

The hosts file contains some comments (lines starting with the # symbol), as well as some default hostname mappings (e.g. 127.0.0.1 – localhost). Simply append your new mappings underneath the default ones. Or edit one of the default values if you know what you are doing! You can navigate the file using the arrow keys.

Step 4 – Save the hosts file

When done editing the hosts file, press control-o to save the file. Press enter on the filename prompt, and control-x to exit the editor.

Step 5 – Flush the DNS cache

On Leopard you can issue a simple Terminal command to flush the DNS cache, and have your host file changes to take immediate effect:

$ dscacheutil -flushcache

You can now test your new mapping on the browser!

Hope this works for you!

0
On

I had to reinstall my setup today and made a step by step at that occasion: I use a combination of Squidman and Mamp Pro (I assume it's similar to XAMPP)—hope this help anyone in their quest; happy to read feedback or get advice to make this better...

Squidman http://squidman.net/squidman/index.html Mamp Pro http://www.mamp.info/en/mamp-pro/

on Squidman - Preferences > General > Http port: something different from the one MAMP is using (if map uses 80, then put 8080)

  • Preferences > Clients > Provide proxy service for: insert the IP address or the subnet we will be catering for

  • Start Squidman

on MAMP:

  • setup the hostname, as well as the the website attached

  • insert the (local) IP address of the local machine

  • insert the port of Apache on the local machine

  • start Mamp; check that website is running correctly on local machine

on iPad/iPhone/mobile device

  • select the same wireless network as the laptop

  • in Wifi network > Preferences/Information: set a Manual HTTP Proxy

  • server IP is the (local) IP address of the Apache server, also running Squidman; port is the port used for Squidman

(Extra)

  • stuff to test: move dev server onto virtual machine (VirtualBox), to use with Node, custom PHP build, etc.

  • automate the setting: write pref for Squidman, Mamp/hostname, restart the Apache server, send configuration of proxy to mobile via iMessage or email.

0
On

On a mac you can use Squid on Windows that's Fiddler, however I'm having troubles with Fiddler and iPhone at the moment...

0
On

I recommend using http://xip.io/. For example (taken from the website):

          10.0.0.1.xip.io   resolves to   10.0.0.1
      www.10.0.0.1.xip.io   resolves to   10.0.0.1
   mysite.10.0.0.1.xip.io   resolves to   10.0.0.1
  foo.bar.10.0.0.1.xip.io   resolves to   10.0.0.1

It does the job and you don't have to set anything up. I'm only pushing it because I am overly excited that I have wasted time trying over-engineered solutions.