从 Android 手机访问开发虚拟机 (Vagrant / VirtualBox)

从 Android 手机访问开发虚拟机 (Vagrant / VirtualBox)

我正在我的电脑上开发一个 Web 应用程序。我的开发环境是 Vagrant / Virtual Box / Ubuntu 14.4。Vagrant 在 上提供应用程序内容10.0.0.101,该内容在我的 hosts 文件中映射到dev.myapp.com。在 Vagrant 内部,nginx 将其重写为https://dev.myapp.com。我想https://dev.myapp.com从我的 Android 手机访问。

我没有太多的网络背景,因此如果下面的一些内容看起来很荒谬,我深表歉意。

到目前为止我尝试过的事情:

  • 在主机上创建了一个临时网络,并用手机连接到该网络,关闭所有其他连接。我可以访问互联网,但无法访问虚拟机 IP 或dev.myapp.com

  • 用的是鱿鱼。思考该过程应该是:Vagrant 提供文件,Squid 将对本地主机的请求转发给 Vagrant,通过 Chrome 配置手机以访问本地主机上的 Squid 端口,手机通过 Squid 和 Chrome 从 Vagrant 接收文件。但是,我无法让 Squid 显示我的服务器。我假设访问localhost:3130(根据我的配置,见下文)应该会导致我看到 Vagrant 提供的应用程序。然而,这并没有发生。

  • 已关注本指南将我的手机反向绑定到主机。无法执行此操作,在 DHCP 步骤上收到超时错误。

是否有捷径可寻?我花了半天时间尝试让它工作,但没有什么成果。

我在 Squid 中从默认配置更改的行:

https_port 3130 transparent cert=/var/certs/myapp.pem key=/var/certs/myapp.key
acl localhost src 127.0.0.1/32 ::1
acl to_localhost dst 10.0.0.101 ::1

这是我的完整 Squid 配置:

#
# Recommended minimum configuration:
#

# Example rule allowing access from your local networks.
# Adapt to list your (internal) IP networks from where browsing
# should be allowed
acl localnet src 10.0.0.0/8 # RFC1918 possible internal network
acl localnet src 172.16.0.0/12  # RFC1918 possible internal network
acl localnet src 192.168.0.0/16 # RFC1918 possible internal network
acl localnet src fc00::/7       # RFC 4193 local private network range
acl localnet src fe80::/10      # RFC 4291 link-local (directly plugged) machines

acl localhost src 127.0.0.1/32 ::1
acl to_localhost dst 10.0.0.101 ::1

acl SSL_ports port 443
acl Safe_ports port 80      # http
acl Safe_ports port 21      # ftp
acl Safe_ports port 443     # https
acl Safe_ports port 70      # gopher
acl Safe_ports port 210     # wais
acl Safe_ports port 1025-65535  # unregistered ports
acl Safe_ports port 280     # http-mgmt
acl Safe_ports port 488     # gss-http
acl Safe_ports port 591     # filemaker
acl Safe_ports port 777     # multiling http
acl CONNECT method CONNECT

#
# Recommended minimum Access Permission configuration:
#
# Deny requests to certain unsafe ports
http_access deny !Safe_ports

# Deny CONNECT to other than secure SSL ports
http_access deny CONNECT !SSL_ports

# Only allow cachemgr access from localhost
http_access allow localhost manager
http_access deny manager

# We strongly recommend the following be uncommented to protect innocent
# web applications running on the proxy server who think the only
# one who can access services on "localhost" is a local user
#http_access deny to_localhost

#
# INSERT YOUR OWN RULE(S) HERE TO ALLOW ACCESS FROM YOUR CLIENTS
#

# Example rule allowing access from your local networks.
# Adapt localnet in the ACL section to list your (internal) IP networks
# from where browsing should be allowed
http_access allow localnet
http_access allow localhost

# And finally deny all other access to this proxy
http_access deny all

# Squid normally listens to port 3128
#http_port 3128
https_port 3130 transparent cert=/var/certs/beta.eclips/full.beta.addtrust.domainval.pem key=/var/certs/beta.eclips/beta.key

# Uncomment and adjust the following to add a disk cache directory.
#cache_dir ufs /var/cache/squid 100 16 256

# Leave coredumps in the first cache dir
coredump_dir /var/cache/squid

#
# Add any of your own refresh_pattern entries above these.
#
refresh_pattern ^ftp:       1440    20% 10080
refresh_pattern ^gopher:    1440    0%  1440
refresh_pattern -i (/cgi-bin/|\?) 0 0%  0
refresh_pattern .       0   20% 4320

相关内容