VMware Communities
nextgengames
Contributor
Contributor

MAMP or Local Web Server

I have a local web server running on MAMP, and want to test in IE. How do i configure vmware to see my apache install on the mac running on 127.0.0.1 ?

Reply
0 Kudos
14 Replies
admin
Immortal
Immortal

127.0.0.1 means "localhost," in other words, "this station." The virtual machine running inside VMware Fusion is a different computer from your Mac host, with a different IP address. So 127.0.0.1 won't work.

Pull down Fusion's Virtual Machine menu, and check out the setting for Network. It'll be one of three choices: Bridged, NAT, or Host-only. Bridged mode makes your virtual machine a peer of your host on your ordinary local network. NAT mode puts the virtual machine behind a software firewall; your Mac acts as your virtual machine's router to your local network. Host-only sets up a private network between your Mac and your virtual machine.

Here's how I remember these modes:

Bridged

Home-or-office mode: makes IP-based file and print sharing easy

NAT

Hotels-and-Starbucks mode: anywhere where it'd be handy to hide the VM behind the host Mac's IP address

Host-only

Airplane mode: no networking beyond the host Mac for the VM

If your VM is in Bridged mode or NAT mode, you can use your host Mac's regular IP address to hit a web server running inside it. If it's in NAT mode, it'll be a little faster if, instead of the host's IP address on your local network, you substitute its address on the NAT network: the same as your VM's IP address, with the last byte replaced by .1. If it's in host-only mode, you have to use the hosts's IP address on the private network: again, the same as your VM's IP address, with the last byte replaced by .1.

Reply
0 Kudos
cgbutler
Contributor
Contributor

I have the same (similar) problem...

My MacBook sits behind a Linksys router/firewall, which assigns 192.168.1.106 to the MacBook.

Fusion/XP can ping 192.168.1.106, but Fusion/XP/IE can't accesss that IP in any permutation I can

think of.

I do AMP web development on the Mac side but need to proof my stuff in Fusion/XP/IE, which is pretty

much why I installed Fusion.

Could be a Linksys /firewall issue, but I can't find an option in the Linksys admin pages to fix this..

Worse: this is a laptop, so it won't always be connected to the Linksys, or even attached to the web.

What IP do I use then?

PS:

Terrible Javascript editor, folks. Blame typos on it, not me. Took forever to write this note....

Reply
0 Kudos
admin
Immortal
Immortal

Sorry you had a hard time with your forum posting. We just cut over to a new forum system within the last month, and there are definitely still some teething pains.

Anyway, cgbutler, you didn't mention what network mode your virtual machine is in (bridged, NAT, or host-only), so I just tried them all on the Core Duo iMac I'm working on right now. I enabled Mac OS's toy Web server, and I was able to hit it using Internet Explorer in a Windows XP virtual machine every time. It worked with the Mac's physical IP address in both bridged and NAT mode; in NAT mode, it also worked using the host's .1 address on the NAT internal network; and in host-only mode, it worked using the .1 address on the host-only internal network.

Then I cut over my Mac's network connection from wired Ethernet to Airport. I was also able to connect to the web server in the host Mac from IE in the virtual machine.

Then I went over to my MacBook Pro, which, unlike my iMac, doesn't have a DNS name registered for it. It thinks its name is "brian-rices-computer.local", which is not a name any DNS server knows about. Aha! Now IE in the VM couldn't hit the Web server in Mac OS.

Here's what the Web server was sending:

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<HTML><HEAD>
<TITLE>301 Moved Permanently</TITLE>
</HEAD><BODY>
<H1>Moved Permanently</H1>
The document has moved
<A HREF="http://brian-rices-computer.local/~brice/">here</A>.<P>
<HR>
<ADDRESS>Apache/1.3.33 Server at brian-rices-computer.local Port 80</ADDRESS>
</BODY></HTML>

Yup, it's redirecting the request to the Mac's canonical name, which is bogus. So to fix this problem, I would need to make sure that my Mac's name is known on its client. I'm running out of time to experiment right now, but you could either arrange for the Mac to have a valid DNS name, or else add an entry for it to C:\Windows\system32\drivers\etc\hosts in your Windows VM.

Reply
0 Kudos
cgbutler
Contributor
Contributor

Brian...

Thanks for the excellent investigation. Your comments echo some from

a friend, and it may be an Apache configuration issue. I'm running

Apache 2, not the default Apache that ships currently with OS X.

FYI, I'm also running the latest version of Tiger.

Sorry I wasn't clearer in my intial post. I tried both bridged and

NAT with no success.

My friend Barry made two good suggestions:

*) Change the "Listen" specification in httpd.conf from 127.0.0.1:80

to 0.0.0.0:80 I was able to connect to 192.168.1.106 from Windows/

IE once that was done.

*) He also suggested permanently assigning an IP to the Mac, one

that works with my Linksys router. That approach should work even

when my MacBook isn't attached to the Linksys. I'm not sure how

that's going to work out with the world's DHCP systems, but it's a

reasonable idea.

Question:

Might it be feasible for VMware to introduce a "magic" host similar

to localhost, to be used on the PC side, intercepted by Fusion, and

mapped to localhost on the Mac side?

Cheers,

Chris

Reply
0 Kudos
admin
Immortal
Immortal

Your friend Barry's idea seems to be to ensure that the DHCP server in your Linksys router always gives your Mac the same IP address. The advantage of doing so is that then you could make a DNS entry for your Mac. This is what I've done for my desktop iMac, and since it's always at home, it works great.

Of course, with laptops, that doesn't work so well. The IP address you get at Starbucks is not going to be the same as the one you get at your cousin's house.

Sure, VMware could come up with some kind of elaborate per-IP-address-and-port remap system, but it'd be a lot of code to solve a really easy problem. I just solved it myself. On my Windows XP VM, I edited C:\windows\system32\drivers\etc\hosts with Notepad, and gave it an entry like this:

192.168.130.78	brian-rices-computer.local brian-rices-computer

Problem solved. Now Apache works with either my host's (bogus) name or IP address. I didn't even have to mess with Apache's configuration on the Mac. If I need to test a website in Internet Explorer while I am in Starbucks, I can just edit that file; no reboot necessary. If I were really lazy, I could give my VM a second virtual network adapter, put this one in host-only mode, and refer to the Mac using its IP address on that host-only network.

This problem will arise anytime you try to hit an Apache installation on a machine without a well-known DNS name, even if virtual machines are nowhere involved.

Reply
0 Kudos
admin
Immortal
Immortal

You know about the telnet trick, right? If you want to find out whether a problem hitting a Web server is due to a network-layer issue or a Web-server configuration issue, just telnet to port 80 on the host machine. If you can make a connection, it's not a network problem.

Reply
0 Kudos
adrianf
Contributor
Contributor

Lots of good tips here but to be honest I really think this is something that could be adressed in future product updates. I used Virtual PC ages ago (2000?) on my mac and had no problems accessing mac webservers in my virtual Win environments. Even when working offline with no assigned IP.

Im willing to bet allot of us paying customers buy Fusion (otherwise a really superb piece of software!) almost solely for the purpose of testing websites etc in IE/Win.

In the meantime. Surely there must be some sort of fancy windows network configuration that can be used to create a static route to the host system regardless of the current IP assigned to the Mac?

Reply
0 Kudos
rcardona2k
Immortal
Immortal

In the meantime. Surely there must be some sort of fancy windows network configuration that can be used to create a static route to the host system regardless of the current IP assigned to the Mac?

Yes, it's called adding a secondary network adapter to your VM using Host-only networking. Your VM and your OS X system will then be on a private network with IPs that work whether OS X's primary connection is up or down. You may need special DNS configuration in your guest's hosts file on the VM to make sure things keep working by name.

Reply
0 Kudos
admin
Immortal
Immortal

Richard, I think the root cause of the problem people are experiencing isn't an IP routing issue, but rather a naming issue. The problem is that modern web servers, if you point a browser at them by an IP address, will send back an HTTP redirect: "Hey, my name ain't 192.168.104.2, it's fred-jones-computer.local! Or Miss Jackson if you're nasty!"

My evidence for believing this is that you can fix the original poster's problem either by making the host Mac's name resolve in DNS, or else adding an entry to the guest's host file. If it were an IP routing issue, those steps wouldn't help.

There's a meaningful enhancement request for VMware here, in my opinion, but it's not related to routing. For virtual network adapters in NAT or host-only mode, the DHCP packet we send them says "Use the host as your DNS server." Maybe the host's mini-DNS-proxy could recognize requests for the host's canonical name ("fred-jones-computer.local") and return a crocked-up response if asking the real DNS about them fails.

(For bridged mode, we're not involved in sending DNS information to the guest OS, so we can't help.)

There's a counter-argument to this approach: we're effectively masking the fact that the host's DNS name is broken. Some people, I am sure, would rather fix the problem. After all, when your Web site goes live, it has to have a valid DNS name; it'd be reasonable to think, "Well, I should go ahead and make sure it has a valid DNS name while it's under development, too."

Reply
0 Kudos
rcardona2k
Immortal
Immortal

Brian, I agree with you 100%. I was on a browser development team in the 90s so I'm totally in tune with the intracies of virtual hosting (sounds backwards for x86 virtualization) and how that affects how IIS and Apache serve their content. I agree that OS X's pseudo-FQDN of hostname.local is corny.

If you look at my response, it's meant to be very targeted, in that if you're totally disconnected, i.e. no active wired or wireless you can reliably depend on a secondary, private host-only network to bridge your host to your guests. You can access MAMP from IE, or IIS from OS X over this nice two-way data path.

The trick as you describe is to have a DNS scheme that supports these routes/connections.

Reply
0 Kudos
blueStarJumper
Contributor
Contributor

check this out:

http://musetracks.instantspot.com/blog/index.cfm/2007/10/30/Make-a-MAMP-Server-Available-Externally

once mamp is available externally you can connect eg

http://192.168.11.4/

this would then point at wherever MAMP's document root (set via Apache prefs) is.

Reply
0 Kudos
vynsane
Contributor
Contributor

using the above method, if you have a built-in airport card (which i think any intel chipset mac has at this point) you can take a look at the network utility and find the IP address assigned to the network interface currently NOT in use through the network - if you are on the airport card, you can use the IP address for Network Interface (en0) and if you're on the wired network, for Network Interface (en1) to access the MAMP localhost through the browser on any virtual machine. since i began using this IP address, it hasn't changed, and i doubt it will, so you could even bookmark it for quick access. it will be in the 172.16.x.x family of private internets (LAN) addresses.

Reply
0 Kudos
brewster
Enthusiast
Enthusiast

Brian, thanks your method works great! I just installed MAMP Pro and was racking my brain how to solve this.

Reply
0 Kudos
remoteONE
Contributor
Contributor

I have same issue, not using Pro, just the free MAMP version. Do I need Pro to make this work?

Setting to Bridged does not work.

My winXP VM is connected to MB OSX SL on IP 192.168.34.1, and browsing to http://192.168.34.1:8888/ shows me the "Index of /"directory structure located under htdocs.

But when trying to load "http://192.168.34.1:8888/any_folder/index.php"  the browser returns "can't establish a connection to the server at localhost:8888."

with the address "http://localhost:8888/any_folder/index.php". changing this to "http://192.168.34.1:8888/any_folder/index.php" again does not work. !

I also  edited C:\windows\system32\drivers\etc\hosts with Notepad  but still no worky !
None of these worked.
#127.0.0.1       localhost      # original setting
172.16.178.1    localhost     # obtained from inet IP address
192.168.34.1    localhost     # obtained from Connection Status in WinXP VM with ".1" at the end.
Edited C:\windows\system32\drivers\etc\hosts and rebooted winXP     ---  but still no worky !
Using http://localhost:8888 in FF winXP will not load anything with any of the above IPs set in hosts file. , it works on the MAMP OSX browsers, but not on the WinXP VM ware FF browser.
This should work... It seems that Win XP is not recognising the settings in the  \etc\hosts file.
Any help please !
Reply
0 Kudos