How to access your virtual host services in VirtualBox with Android emulator.
purpose
I built local development with Vagrant. I can browse http://text.example.com with Google Chrome, Firefox and Safari in MacOS.
But I want to browse test application running in VirtualBox by Android emulator.
my enviroments
- MacOSX 10.8
- nginx/1.4.4
- VirutualBox 4.2.10
- Genymotion 2.0.3
edit emulator hosts file
adb pull /system/etc/hosts /tmp/hosts echo "192.168.57.1 test.example.com" >> /tmp/hosts adb remount adb push /tmp/hosts /system/etc
edit local hosts file
sudo echo "xxx.xxx.xxx.xxx test.example.com >> /etc/hosts
xxx.xxx.xxx.xxx is my VirtualBox IP address.
edit proxy server conf file.
here is example.
% cat /usr/local/etc/nginx/text.proxy.conf
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name test.example.com;
location / {
proxy_pass http://test.example.com;
}
}
}
start nginx.
sudo nginx -c /usr/local/etc/nginx/test.proxy.conf -s reload
enjoy!!