【问题标题】:iis reverse proxy showing error 404 for servicesiis 反向代理显示服务的错误 404
【发布时间】:2020-11-30 02:27:18
【问题描述】:

我有带有 WCF 服务的 Asp.net MVC 4 应用程序。项目托管在 iis 生产服务器 P125 (10.10.10.125) 中,同一服务器上托管的其他站点很少。我们的 Web / 前端服务器用作生产服务器的反向代理(已安装 URL 重写和应用程序请求路由),

185.132.x.x 是仅作为反向代理的 Web 服务器的公共 IP (Windows Server 2016)。

我们的应用程序托管在应用程序服务器 ip 10.10.10.125 的端口 8899

185.132.x.x:8080 10.10.10.125:8899

网站运行良好,MVC 应用程序的所有页面/操作都运行良好,除了服务(rest.svc,winact.svc

每当我们点击 185.132.x.x:8080/rest.svc 时都会显示错误:

The resource cannot be found.
Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable.  Please review the following URL and make sure that it is spelled correctly.

Requested URL: /rest.svc

我不知道为什么? 我们所有的服务都显示相同的错误,而服务在本地网络以及 WebServer 本身的 10.10.10.125:8899/rest.svc 上运行良好。

远程登录 WebServer(185.132.xx) 并通过 10.10.10.125:8899 浏览/访问应用程序和服务 (.svc),它工作正常。

我正在使用反向代理:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="ReverseProxyInboundRule1" stopProcessing="true">
                    <match url="(.*)" />
                    <action type="Rewrite" url="http://10.10.10.125:8899/{R:1}" />
                </rule>
            </rules>
            
        </rewrite>
    </system.webServer>
</configuration>

【问题讨论】:

    标签: asp.net asp.net-mvc url-rewriting reverse-proxy arr


    【解决方案1】:

    花了 48 小时后我发现,配置 serviceHostingEnvironment 解决了服务问题 (.svc) 和我在 WebServer(185.132. xx) 就像:

    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
     <system.web>
        <customErrors mode="Off"/>
        <compilation debug="false" targetFramework="4.5"/>
        <httpRuntime targetFramework="4.5" />
        <pages>
          <namespaces>
            <add namespace="System.Web.Helpers"/>
            <add namespace="System.Web.Mvc"/>
            <add namespace="System.Web.Mvc.Ajax"/>
            <add namespace="System.Web.Mvc.Html"/>
            <add namespace="System.Web.Optimization"/>
            <add namespace="System.Web.Routing"/>
            <add namespace="System.Web.WebPages"/>
          </namespaces>
        </pages>
      </system.web>
     <system.serviceModel>
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
      </system.serviceModel>
        <system.webServer>
            <rewrite>
                <rules>
                    <rule name="ReverseProxyInboundRule1" stopProcessing="true">
                        <match url="(.*)" />
                        <action type="Rewrite" url="http://10.10.10.125/{R:1}" />
                    </rule>
                </rules>
            </rewrite>
        </system.webServer>
    </configuration> 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-04-23
      • 2020-02-19
      • 2011-12-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多