Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I've disabled the web server on Snow Leopard, and I'm using an emulated Ubuntu with Lighttpd web server.

In order to access to the web pages I need to specify the ip of the emulated machine. However I now need to associated such ip with "localhost" in Leopard environment.

When I type localhost in Leopard I actually want to visit the localhost on the Ubuntu machine.

Do I need apache on leopard to make the forward or can I change network settings in Leopard or what ?

thanks

share|improve this question
    
When you say "an emulated Ubuntu", I assume you mean that you're running Ubuntu in a virtual machine hosted on your Snow Leopard box, right? If that's right, which VM software are you using? VMWare Fusion? Parallels? VirtualBox? –  Doug Harris Dec 30 '10 at 15:42
    
@Doug Harris VMWare Fusion –  Patrick Dec 30 '10 at 15:42
    
Also a quick temporary shell solution is fine... (I mean, from shell to specify localhost=000.000.000.000) –  Patrick Dec 30 '10 at 15:43

2 Answers 2

up vote 1 down vote accepted

I would not recommend changing your loopback address of your system. However, what you can do is define a human-friendly alias in /etc/hosts file on your OS X that will point to the IP of your Ubuntu box. For example:

192.168.0.1    ubuntu

You might be tempted to change the localhost alias in /etc/hosts but I would not recommend that; if you read the comments on top of that file, you will find a warning that will tell you not to change the localhost alias. I will quote the warning as is from the copy of /etc/hosts I have on Snow Leopard:

Host Database

localhost is used to configure the loopback interface when the system is booting. Do not change this entry.

share|improve this answer
    
@ajaz I forgot to mention that since the ip of my virtual machine chenges, also a shell solution is acceptable. In other terms, I need anyway to set it everytime I restart the virtual machine, so could I set it from shell ? –  Patrick Dec 30 '10 at 15:38
    
+1 for not changing the IP address for localhost. Seems like a really bad idea. –  Doug Harris Dec 30 '10 at 15:42
    
Patrick, I've a very similar setup on my MacBook where I run Slackware inside VMware and access it from OS X via the hosts alias slackware. If you are usually connected to the same network, it might be a better trade-off to assign a static IP to your VMware host and define an alias for it in /etc/hosts –  ayaz Dec 30 '10 at 16:13

Restating the problem: Your desired goal is to type "http://localhost" into your web browser and have that served by the virtual machine.

Possible solutions:

mod_proxy - Re-enable Apache under Snow Leopard, set up mod_proxy as a transparent proxy to the web server on your virtual machine.

port mapping - Rather than setting up your VMWare VM to use NAT-mode instead of bridged mode. This means that your VM doesn't have its own IP address on your main LAN but instead VMWare creates a pseudo network within your machine. From here, you can set up port mapping so that when your mac takes requests on port 80, they're forwarded to your VM. A quick Google search found one person's notes on doing something like this.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.