0

I'm new to Linux and I want to set up a Virtualbox web server to keep OSX clean.

I have set up a headless Debian server with Apache2, Avahi, and ssh.

What I'd like the server to do:

  • Be accessible with or without a local network (i.e. without a router)
  • Not require any modifications to the hosts file on the host machine.
  • Be abler to resolve sub-domains on either dev-vm.local or dev-vm.com for example.

How it works now

  • Apache default responds to 192.168.2.13 and dev-vm.local
  • I can access sub-domains if I add 192.168.2.13 to my OSX hosts file, but I'd like to avoid that.
  • I can ssh to 192.168.2.13 but not the vboxnet0 IP (10.0.0.20).

If I type in dev-vm.local in my browser I get the server root, which is fine, but if I try to access test.dev-vm.local the domain can't be resolved.

My ghost file is as following

<VirtualHost *:80>
    DocumentRoot /var/www/test
    ServerName test.dev-vm.local
    ServerAlias tester.dev-vm.local
    ServerAlias test.vm.dev

    <Directory /var/www/test/>
            Options +FollowSymLinks Indexes
            AllowOverride All
            order allow,deny
            allow from all
    </Directory>

As said, it responds to test.vm.dev if I add

192.168.2.13 test.vm.dev

to OSX' host file.

It does not respond to test.dev-vm.local nor tester.dev-vm.local. Which I would prefer.

Virtualbox is set up with a

  • Bridged Adapter on eth0 (Promiscuous Mode:Deny)
  • vboxnet0 on eth1 (Promiscuous Mode:Allow All)

Under Virtualbox settings vboxnet0 has the following properties

Adapter:
IPv4Adress 10.0.0.2
IPv4 Network Mask 255.255.255.0

DHCP Server:
Server Address: 10.0.0.1
Server Mask: 255.255.255.0
Lower Address Bound 10.0.0.20
Upper Address Bound 10.0.0.20

On the guest web server I have the following settings:

/etc/network/interfaces:

# The loopback network interface
auto lo eth0 eth1
iface lo inet loopback

# The primary network interface
allow-hotplug eth0
iface eth0 inet dhcp

iface eth1 inet dhcp

/etc/apache2/apache2.conf has the following added:

ServerName localhost

Sorry if something is unclear but since I'm new to this I don't know if I included the necessary info.

But if someone could point me in the right direction I would appreciate it!

1 Answer 1

1

For your web server to handle sub domain requests, the query should reach it. But, as far as I understand you are adding only the host name of the web server to your hosts file. So a request with a subdomain address is not being directed to virtual machine. You have two options. You should either add all subdomains to your hosts file, which may be short and simple solution here or setup a dns server to handle all your virtual env. addresses. If you just have one vm than DNS solution is more expensive, but if you will have many vms with lots of subdomain addresses it may be a sol

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .