IISExpress 从远程计算机返回 503 错误

发布于 2024-10-26 18:35:45 字数 401 浏览 6 评论 0原文

我正在尝试使用本地网络上的一些其他计算机/设备测试在本地 IISExpress 实例中运行的网站。我运行的是Win7专业版。

当我第一次尝试从本地网段上的另一台计算机浏览到我的计算机时,收到 400 错误:主机名无效。

我知道我需要使用提升的命令提示符上的命令授予对 ACL 的远程访问权限,例如:

netsh http add urlacl url=http://mymachinename:50333/ user=everyone

现在我得到了503服务不可用错误。

Windows 防火墙当前已关闭,我可以通过地址 http://localhost:50333 浏览本地 IISExpress 实例

此配置难题的最后一部分是什么?

I'm attempting to test a website I have running in a local IISExpress instance with some other machines / devices on my local network. I am running Win7 Pro.

When I first attempt to browse to my machine from another machine on my local network segment, I get a 400 error: Hostname is invalid.

I understand that I need to grant remote access to the ACL with a command on the elevated command prompt like:

netsh http add urlacl url=http://mymachinename:50333/ user=everyone

Now I get a 503 service is unavailable error.

Windows Firewall is currently shut off, and I am able to browse my local IISExpress instance with the address http://localhost:50333

What is the final piece to this configuration puzzle?

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

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

发布评论

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

评论(10

沧桑㈠ 2024-11-02 18:35:45

您似乎在 applicationhost.config 文件中缺少绑定信息条目。

  1. 打开您的 applicationhost.config 文件。可能的位置是:

    • %userprofile%\Documents\IISExpress\config\applicationhost.config
    • $(solutionDir)\.vs\config\applicationhost.config (VS2015)
    • 如果失败,请检查 iisexpress.exe 的输出以确定。
  2. 找到您的网站条目并添加以下与您的计算机名称的绑定。

     <绑定协议=“http”绑定信息=“:50333:您的机器名称”/> />
    
  3. 重新启动 IIS Express

It looks like you are missing a binding information entry in applicationhost.config file.

  1. Open your applicationhost.config file. Possible locations are:

    • %userprofile%\Documents\IISExpress\config\applicationhost.config
    • $(solutionDir)\.vs\config\applicationhost.config (VS2015)
    • Failing that, inspect the output from iisexpress.exe to be sure.
  2. Locate your WebSite entry and add following binding with your machine name.

         <binding protocol="http" bindingInformation=":50333:your-machine-name" />
    
  3. Restart IIS Express

┼── 2024-11-02 18:35:45

只有一件事对我有用。

使用 *:portnumber:* 是不好的。是的,完成此操作并确保 Windows 防火墙已打开后,我可以连接到该端口,但仍然收到“503”错误。

我在本地测试了一些东西,发现只有 http://localhost 有效。使用真实 IP 地址(不是 127.0.0.1,而是 192.168.1.50),即使在本地计算机上仍然返回 503。我尝试在绑定中使用真实主机名,但 IIS Express 拒绝启动。这实际上可能与主机名的解析方式有关。我没有进一步探讨这一点。

最后,我最终使用了这个配置:

<binding protocol="http" bindingInformation="*:53351:localhost" />
<binding protocol="http" bindingInformation="192.168.1.50:53351:*" />

这样,我就能够使用 http://192.168.1.50:53351 从远程计算机进行连接。

There was only 1 thing that worked for me.

using *:portnumber:* was no good. Yes, after doing that and making sure the Windows Firewall was open, I could connect to the port, but I still got the "503" error.

I tested a few things locally, and discovered that only http://localhost worked. Using the real IP address (not 127.0.0.1, but, for instance, 192.168.1.50), still returned a 503 even on the local machine. I tried using the real host name in the bindings, but IIS Express refused to start. This may actually have something to do with how the host name was being resolved. I didn't explore that further.

Finally, I ended up using this configuration:

<binding protocol="http" bindingInformation="*:53351:localhost" />
<binding protocol="http" bindingInformation="192.168.1.50:53351:*" />

In that way, I was able to connect from a remote machine using http://192.168.1.50:53351.

清风无影 2024-11-02 18:35:45

在如此完整的主题上浪费了 3 个多小时后,我决定与您分享我的设置。
我的配置是 Windows 8 上的 Visual Express 2012 for Web update 4。这是我自学习以来(至少 8 年)第一次回到 MS VS,现在我确信 Linux 占主导地位。在 django 上,这种设置花了我 10 分钟的时间搜索文档。

  1. 关闭防火墙进行测试

    netsh advfirewall 将所有配置文件状态设置为关闭
    
  2. 在我的情况下设置绑定本地地址是 localIP=192.168.1.102 (因为链接不能包含非数字域,请在下面使用它而不是 mylocaldomain.com,请参阅 stackoverflow 策略)
    Documents\IISExpress\config\applicationhost.config

    <前><代码><绑定>
    <绑定协议=“http”绑定信息=“*:53351:mylocaldomain.com”/>
    <绑定协议=“http”绑定信息=“*:53351:localhost”/>

  3. 为ISS Express自动启动服务添加自动运行

    <站点名称=“NeuronCharts”id=“2”serverAutoStart=“true”>
    
  4. 向 http 服务器添加一些奇怪的规则(我仍然不知道这是否有必要)

    netsh http add urlacl url=http://mylocaldomain.com:53351/ user=everyone
    
  5. 手动运行IISExpress而不是从VS IDE

  6. 你会看到ISSExpress 正在注册绑定
  7. 运行浏览器 http://mylocaldomain.com:53351
    如果它正常工作,那么我们可以添加防火墙规则
  8. 添加防火墙规则

    netsh advfirewall 防火墙添加规则名称=“IISExpressWeb”dir=in 协议=tcp 本地端口=53351 远程 IP=任何操作=允许
    

集remoteip到any如果你想从外部世界访问你的服务器如果你想访问本地网络使用localsubnet

  1. 启动防火墙

    netsh advfirewall 将所有配置文件状态设置为开启
    
  2. 再次检查本地和公共IP上的一切是否正常

祝你好运

Rafal

After wasting more than 3h on such a full subject I decided to share my setup with you.
My configuration is Visual Express 2012 for Web update 4 on windows 8. This was my first come back to MS VS since studies (at least 8 years) and now I'm sure that linux rules. On django this kind of setup took me 10min of searching documentation.

  1. turn off firewall for testing

    netsh advfirewall set allprofiles state off
    
  2. setup bindings in my case local address is localIP=192.168.1.102 (because links can not contain nonnumeric domain, use it below instead of mylocaldomain.com, see stackoverflow policy)
    in Documents\IISExpress\config\applicationhost.config

    <bindings>
        <binding protocol="http" bindingInformation="*:53351:mylocaldomain.com" />
        <binding protocol="http" bindingInformation="*:53351:localhost" />
    </bindings>
    
  3. add autorun for ISS Express start service automatically

    <site name="NeuronCharts" id="2" serverAutoStart="true">
    
  4. Add some weird rules to http server (I still do not know if this is nesseary)

    netsh http add urlacl url=http://mylocaldomain.com:53351/ user=everyone
    
  5. run IISExpress manually not from VS IDE

  6. you will see that ISSExpress is registering bindings
  7. run browser http://mylocaldomain.com:53351
    if it is working then we can add firewall rule
  8. add firewall rule

    netsh advfirewall firewall add rule name="IISExpressWeb" dir=in protocol=tcp localport=53351 remoteip=any action=allow
    

set remoteip to any if you want to access you server from outside world if you want to access for local network use localsubnet

  1. start firewall

    netsh advfirewall set allprofiles state on
    
  2. check again if everything is working on local and public ip

Wish you luck

Rafal

小鸟爱天空丶 2024-11-02 18:35:45

发现问题与错误的 urlacl 映射有关。要弄清楚这一点:

netsh http show urlacl 

并查找诸如 http://+:80/ 或您绑定到的端口之类的内容。

然后使用

netsh http delete url=<the url from the list>

这解决了我的问题。

Found the problem had to do with a bad urlacl mapping. To figure this out:

netsh http show urlacl 

and look for things like http://+:80/ or the port you are binding to.

Then use

netsh http delete url=<the url from the list>

This fixed the problem for me.

能否归途做我良人 2024-11-02 18:35:45

没有什么对我有用。最后我找到了 iisexpress-proxy

查看我的答案https://stackoverflow.com/a/33623399/631527

另一个解决方案是ngrok

Nothing worked for me. Finally I found iisexpress-proxy

See my answer https://stackoverflow.com/a/33623399/631527

Another solution is ngrok

帅冕 2024-11-02 18:35:45

对我有帮助的是右键单击“IISExpress”图标,“显示所有应用程序”。然后选择该网站,我看到它使用哪个 aplicationhost.config,并且更正进行得非常完美。

IISExpress 配置

What helped me, was right clicking the 'IISExpress' icon, 'Show All applications'. Then selecting the website and I saw which aplicationhost.config it uses, and the the correction went perfectly.

IISExpress configuration

客…行舟 2024-11-02 18:35:45

问题是更新 web 文件夹中的 applicationhost.config 文件而不是解决方案的文件。解决方案配置文件是要更改的文件

The problem is updating the applicationhost.config file inside the web folder instead of the solution's. The solution config file is the one to change

拧巴小姐 2024-11-02 18:35:45

关于 Anthony Rizzolo 的回答:在 Windows 8.1 中,我必须这样输入:

netsh http delete urlacl url=<the url from the list>

例如:

netsh http delete urlacl url=http://+:8689/

Regarding Anthony Rizzolo's answer: in Windows 8.1, I had to type like this:

netsh http delete urlacl url=<the url from the list>

For example:

netsh http delete urlacl url=http://+:8689/
离笑几人歌 2024-11-02 18:35:45

@vikomall 解决方案后,不要忘记以管理员身份启动 VS。
这帮我解决了。

After solution of @vikomall don't forget to start VS as adminisrator.
This fix it for me.

没有伤那来痛 2024-11-02 18:35:45

上面的答案都不适合我。

我在 netsh 中有两个条目用于同一服务

netsh http show urlacl

在此处输入图像描述

一个使用强通配符,另一个使用弱通配符。

删除通配符弱的那个就可以了。

有关 netsh 上下文中强通配符和弱通配符的更多信息

当 UrlPrefix 的主机元素由单个加号组成时
(+),UrlPrefix 匹配上下文中所有可能的主机名
它的方案、端口和relativeURI元素,并且属于强
通配符类别。

当星号 (*) 作为宿主元素出现时,则 UrlPrefix
属于弱通配符类别。这种UrlPrefix匹配
与指定方案、端口和关联的任何主机名
尚未与强通配符匹配的relativeURI,
显式或 IP 绑定弱通配符 UrlPrefix。本主机规格
在某些情况下可以用作默认的包罗万象,或者可以
用于指定一大段 URL 命名空间,而无需使用
许多 URL 前缀。

https://learn.microsoft.com/en-gb/ windows/desktop/Http/urlprefix-strings

None of the answers above worked for me.

I have had two entries in netsh for the same service

netsh http show urlacl

enter image description here

One using a strong wildcard, the other one using a weak wildcard.

Removing the one with the weak wildcard did the job.

More about the strong and weak wildcard in the context of netsh

When the host element of a UrlPrefix consists of a single plus sign
(+), the UrlPrefix matches all possible host names in the context of
its scheme, port and relativeURI elements, and falls into the strong
wildcard category.

When an asterisk (*) appears as the host element, then the UrlPrefix
falls into the weak wildcard category. This kind of UrlPrefix matches
any host name associated with the specified scheme, port and
relativeURI that has not already been matched by a strong-wildcard,
explicit, or IP-bound weak-wildcard UrlPrefix. This host specification
can be used as a default catch-all in some circumstances, or can be
used to specify a large section of URL namespace without having to use
many UrlPrefixes.

https://learn.microsoft.com/en-gb/windows/desktop/Http/urlprefix-strings

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