查看 LAN 上不同主机名下的本地网站
简而言之,我正在尝试使用 .local
主机名浏览本地 wifi 网络上的 Mac 网站,该主机名与计算机的“计算机名称”不同,并且认为我错过了设置步骤。
我在 Macbook 上本地安装了 nginx,并使用适当的 /etc/hosts
和 nginx.conf
条目来服务多个站点,每个站点都有自己不同的本地主机名。假设 Macbook 的网络名称是computername.local,并且我正在运行 2 个站点,其中一个位于 http://computername.local ,另一个位于 http://servicename.local。我可以从本地计算机很好地访问这些网站,但也希望能够访问 http://servicename.local 来自同一 WiFi 网络上的 iPhone。我发现该 URL 超时,但另一个 URL 工作正常。
我猜想必须采取一些措施才能允许在本地网络上使用 servicename.local ,而我已经遗漏了这一点。这样做需要什么?我需要使用 Bonjour 吗?我应该在哪里添加这个新的本地主机名?
如果我也在其 /etc/hosts
文件中定义 IP,同一网络上的另一台 Mac 也可以访问 servicename.local 下的这个文件,但显然我无法在 iPhone 上修改该文件。它没有越狱,而且我并不是真的有兴趣这样做只是为了让它工作。
In short I'm trying to browse a Mac's web site on the local wifi network under a .local
hostname that is not the same as the machine's 'computer name' and think I'm missing a setup step.
I have a local install of nginx on my Macbook, with the proper /etc/hosts
and nginx.conf
entries to serve multiple sites, each with their own distinct local hostname. Assume the Macbook's network name is computername.local, and I have 2 sites running, one at http://computername.local and another at http://servicename.local. I can access each of these sites just fine from the local machine, but also want to be able to access http://servicename.local from an iPhone on the same WiFi network. I'm getting a timeout for that URL, but the other one works just fine.
I'm guessing something has to be done to allow servicename.local to be used on the local network, which I've left out. What is required to do that? Do I need to use Bonjour for that? Where would I add this new local hostname?
Another Mac on the same network can access this one under servicename.local just fine if I define the IP in its /etc/hosts
file too, but I can't modify that file on the iPhone obviously. It's not jailbroken, and I'm not really interested in doing that just to get this working.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不确定它是否会对 OP 有帮助,但除了运行 DNS 服务器或越狱手机之外,另一种方法是在 Mac 上运行 HTTP 代理,并将 iPhone 配置为使用代理。然后,iPhone 将获取 Mac 的本地主机文件条目,因为它通过代理解析 DNS 查询。我在博客中介绍了如何使用免费的 Mac 代理“SquidMan”执行此操作:http://egalo.com/99j< /a>
Not sure if it will help the OP, but another way of doing this - besides running a DNS server or jailbreaking the phone - is to run an HTTP proxy on the Mac, and configure the iPhone to use the proxy. Then the iPhone will pick up the Mac's local hosts file entries because it resolves DNS queries through the proxy. I've blogged about how to do this using the free Mac proxy "SquidMan" here: http://egalo.com/99j