Forum

access host website from virtualbox machine

kfft
28 October 2017, 05:55
Hello

I am trying to access my host's Hiawatha website from my VirtualBox machine.
In the VirtualBox machine I access http://10.0.2.2, (the gateway's address in the virtual machine mapping to the host's local address)
On the host I have configured:
* a default Website with Hostname = 0.0.0.0
* a VirtualHost with Hostname = 127.0.0.1,10.0.2.2

The access logs show that accessing from 10.0.2.2 ends up in the default Website and shows in the log :
127.0.0.1 - - [28/Oct/2017:14:28:08 +0100] "GET / HTTP ...

My question: if the log shows 127.0.0.1 why does it end up in the default website?
I would like 10.0.2.2 to access the VirtualHost. How can I catch it then?
Accessing my website from the host using http://127.0.0.1 correctly accesses the VirtualHost

Thanks for your help
kfft
28 October 2017, 18:54
I am therefore accessing the webserver from a virtual machine on http://10.0.2.2 (VirtualBox network NAT configuration), the site is served by the host.
I have tried a VirtualHost with Hostname=127.0.0.1,10.0.2.2,localhost,192.168.1.100
but still can't catch it and the webserver ends up on the default website.
Where can I see the Hostname actually used for this local connection that I should use for the VirtualHost?

Hugo Leisink
29 October 2017, 20:46
I have no idea why it doesn't work. Hiawatha's (virtual) host matching works as intended. You're sure you didn't make any typo somewhere?
kfft
30 October 2017, 08:35
yes I agree it is probably something stupid on my side.

I thought VirtualBox NAT was just mapping the guest 10.0.2.2 to the host 127.0.0.1 but it seems there is something else otherwise it would end up in my Virtualhost referencing 127.0.0.1.

Therefore, where can I see the exact address as used for host matching? I want to see the actual name that ended up in default so that I can redirect it to the VirtualHost instead.

Hugo Leisink
30 October 2017, 08:46
It should be visible in the access logfile. Look for a header named 'Host:'.
kfft
30 October 2017, 20:58
Sorted out in 1 min thanks to your help:
I switched to the Hiawatha log instead of the extended log to get more information and see the Host which was missing in the extended log.
I could spot that the host used was 10.0.2.2 - the one typed in the browser before conversion by the VirtualBox NAT into 127.0.0.1.
After forcing a refresh of the browser, I eventually got access to the VirtualHost!
Conclusion: use the default hiawatha log format to get more information for debug, it is the best and most readable format!

[the topic can be closed]
Chris Wadge
31 October 2017, 10:36
Note that VirtualBox interfaces can also be run in bridged network mode, which avoids NAT problems entirely.
This topic has been closed.