Is there a way to "redirect" a click on a URL in a VirtualBox guest to open in the host OS browser?
Theoretically yes. You could have a stub handler within the guest send a message to a daemon running on the host which actually invokes the proper application. I've never seen such a setup myself though.
If there was such a way, it would be an enormous security hole.
The most you can do is use the Shared Clipboard: With Guest additions installed, the clipboard of your guest OS can be shared with your host OS.
I had the same idea as Ignacio Vazquez-Abrams and I implemented it.
So the first part of this is an HTTP server that listens to requests on the machine where you want to open the browser. On an incoming request it opens (in a browser) the URL given as an argument of a POST request.
Pick one:
- Python script, no dependencies: browser_daemon.py
- Python script, requires Flask: browser_daemon_flask.py
You should add this script to startup, it's supposed to run in the background.
The second part is something that invokes the request.
Pick one:
- Shell script, requires curl: open_url.sh
- Python script, no dependencies: open_url.py
You should designate this script as your default browser. How to do that is... a separate question. You can search for something like "windows set custom executable as default browser".
It can also be used as a command line tool: ./open_url.py 'http://google.com/'
The Python scripts should work on all major systems with any reasonably recent Python version (I suspect 2.6+, 3.1+).
On Windows, if you don't want a Python script to run in a command window, you should change its extension to .pyw
. Use Task Manager if you want to stop it (look for pythonw.exe).
VirtualBox network adapter should be set to NAT (default setting). More about the IP address here. The choice of port is arbitrary, feel free to change 1337 to something else everywhere.
The server is secure because it listens only to connections from localhost. VirtualBox makes it work somehow. But if you want this to work remotely, specify the listening IP address as '0.0.0.0'
or ''
instead of 'localhost'
.