从虚拟机访问本地主机

发布于 2024-12-28 15:33:44 字数 161 浏览 6 评论 0原文

我需要从虚拟机内部访问本地环境。有几篇关于如何执行此操作的帖子,但我需要能够通过在地址栏中键入“localhost”来访问我的本地主机,因为它使用 facebook 身份验证,如果域无法识别,则它不起作用。

如何设置以使虚拟机中的“localhost”指向虚拟机外部的“localhost”?

I need to access my local environment from inside a vm. There's several posts about how to do this, but I need to be able to access my localhost by typing "localhost" in the address bar, because it uses facebook authentification, and if the domain is not recognized, it doesn't work.

How can I set so that "localhost" in my vm points to "localhost" outside the vm ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夜空下最亮的亮点 2025-01-04 15:33:44

您可以将本地主机的 IP 地址更改为主机文件中主机的 IP 地址。

如果虚拟机是 Windows,则文件位于 c:\windows\system32\drivers\etc\hosts

只需在记事本中打开主机文件并编辑

127.0.0.1 localhost

192.168.0.1 localhost

不确定它是否有效,但您至少可以尝试

you can change the IP address of the localhost to whatever the IP of the host has in your hosts file.

If the vm machine is windows the file is located at c:\windows\system32\drivers\etc\hosts

just open up the hosts file in notepad and edit

127.0.0.1 localhost

to

192.168.0.1 localhost

not sure if it works, but you can atleast try

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文