在 IIS 7 中从本地网络中的另一台计算机访问本地网站 [英] Accessing a local website from another computer inside the local network in IIS 7
问题描述
好的,下面是场景:
我的本地网络中有计算机 A 运行 IIS 7.我通过 IIS 管理器添加了一个新网站,比如说 samplesite.local,并编辑了 hosts 文件在 %systemroot%system32driversetc 里面加上这个新行:
127.0.0.1 samplesite.local
因此,在计算机 A 上运行的浏览器中,如果我在地址栏中键入 samplesite.local 并按 Enter,一切正常.我可以访问该网站.
现在我想从其他本地计算机访问这个网站,例如,计算机 B 或 iPad,不是从外部世界,而是从同一个本地网络内部.
有什么想法吗?
计算机 A 的 IP 是 192.168.1.100,samplesite.local 在端口 80 上运行.但是,如果我在任何计算机的浏览器地址栏中输入 192.168.1.100,我会被带到默认的 IIS 网站,即带有 IIS 徽标的网站,其物理地址是 C:inetpubwwwroot,而不是 samplesite.local.
为您的网站添加两个绑定,一个用于本地访问,另一个用于 LAN 访问,如下所示:
打开 IIS 并从左侧面板中选择您的本地网站(您希望从本地网络访问的网站):
<块引用>连接 > 服务器(用户 PC)> 站点 > 本地站点
在Actions标签下的右侧面板中打开Bindings添加这些绑定:
本地:
<块引用>类型:httpIP 地址:全部未分配端口:80主机名:samplesite.local
局域网:
<块引用>类型:httpIP 地址:<主机的网络地址 ex.192.168.0.10>端口:80主机名:<留空>
瞧,您应该可以通过使用主机的 LAN IP 地址(上例中为 192.168.0.10)作为站点 url 从本地网络上的任何计算机访问该网站.
注意:
如果您想使用主机名(如 samplesite.local)而不是 IP 地址从 LAN 访问网站,请将主机名添加到本地网络机器上的 hosts 文件中(主机文件可以在 "C:WindowsSystem32driversetchosts" 在 windows 中,或 "/etc/hosts" 在 ubuntu 中):
<块引用>192.168.0.10 samplesite.local
Ok, so here is the scenario:
I have computer A inside my local network running IIS 7. I added a new website, let's say samplesite.local, through IIS Manager, and edited the hosts file inside %systemroot%system32driversetc with this new line:
127.0.0.1 samplesite.local
So, in a browser running in computer A, if I type samplesite.local in the address bar and hit Enter, everything works fine. I can access the website.
Now I wanted to access this website from other local computers, say, computer B or an iPad, not from the outside world, but from inside the same local network.
Any thoughts?
Edit: Computer A's IP is 192.168.1.100, and samplesite.local is running on port 80. However, if I type 192.168.1.100 in any computer's browser's address bar, I'm taken to the default IIS website, the one with the IIS logo, whose physical address is C:inetpubwwwroot, not to samplesite.local.
Add two bindings to your website, one for local access and another for LAN access like so:
Open IIS and select your local website (that you want to access from your local network) from the left panel:
Connections > server (user-pc) > sites > local site
Open Bindings on the right panel under Actions tab add these bindings:
Local:
Type: http Ip Address: All Unassigned Port: 80 Host name: samplesite.local
LAN:
Type: http Ip Address: <Network address of the hosting machine ex. 192.168.0.10> Port: 80 Host name: <Leave it blank>
Voila, you should be able to access the website from any machine on your local network by using the host's LAN IP address (192.168.0.10 in the above example) as the site url.
NOTE:
if you want to access the website from LAN using a host name (like samplesite.local) instead of an ip address, add the host name to the hosts file on the local network machine (The hosts file can be found in "C:WindowsSystem32driversetchosts" in windows, or "/etc/hosts" in ubuntu):
192.168.0.10 samplesite.local
这篇关于在 IIS 7 中从本地网络中的另一台计算机访问本地网站的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!