Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在windows 8和XP中,从虚拟机中的来宾机访问本地主机上的应用程序_Windows_Virtualbox - Fatal编程技术网

在windows 8和XP中,从虚拟机中的来宾机访问本地主机上的应用程序

在windows 8和XP中,从虚拟机中的来宾机访问本地主机上的应用程序,windows,virtualbox,Windows,Virtualbox,我无法通过来宾计算机上的localhost访问主机上运行的应用程序。我已经回顾并尝试实现了几个答案,但我无法在XP和Windows 8中访问localhost(Windows 7工作正常) 我在所有虚拟机上的配置: VirtualBox:我有一个网络适配器,设置为NAT OS:我已将10.0.2.2 localhost添加到C:\WINDOWS\System32\drivers\etc\hosts 在我的主机上运行于:4567的应用程序可以通过http://10.0.2.2:4567但不是ht

我无法通过来宾计算机上的
localhost
访问主机上运行的应用程序。我已经回顾并尝试实现了几个答案,但我无法在XP和Windows 8中访问
localhost
(Windows 7工作正常)

我在所有虚拟机上的配置:

  • VirtualBox:我有一个网络适配器,设置为
    NAT
  • OS:我已将
    10.0.2.2 localhost
    添加到
    C:\WINDOWS\System32\drivers\etc\hosts
  • 在我的主机上运行于
    :4567
    的应用程序可以通过
    http://10.0.2.2:4567
    但不是
    http://localhost:4567
我有几个大型应用程序与我目前正在测试的应用程序交互,所有硬代码资源都被分配到
localhost
,因此使用
localhost
之外的任何东西都是行不通的。
我知道这并不理想,但我现在没有时间让事情变得更灵活:\

如果您只需要快速解决,您只需要在来宾服务器上安装一个Apache HTTP服务器,作为对主机的反向代理。配置应该类似于:

<VirtualHost *:4567> 
# 
ServerName localhost
ProxyPass / http://10.0.2.2:4567/
ProxyPassReverse / http://10.0.2.2:4567/
#
</VirtualHost>

# 
服务器名本地主机
ProxyPass/http://10.0.2.2:4567/
ProxyPassReverse/http://10.0.2.2:4567/
#

你说得很好。理想情况下,我不想代理这样的事情,但如果没有其他选择,我会走这条路。