2

我正在托管一个位于负载均衡器后面的私有 NuGet 服务器。负载均衡器接受 ssl 流量 (442) 并转发到 Web 服务器上的端口 80。

NuGet 似乎正在检测请求协议并返回带有 http 与 https 的基本 href。

因此,对https://nuget.privaterepo.org的请求将返回以下内容:

<service xml:base="http://nuget.privaterepo.org/nuget/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:app="http://www.w3.org/2007/app" xmlns="http://www.w3.org/2007/app">
  <workspace>
    <atom:title>Default</atom:title>
    <collection href="Packages">
      <atom:title>Packages</atom:title>
    </collection>
  </workspace>
</service>

这应该<service xml:base="http://nuget.privaterepo.com/nuget/"...引起<service xml:base="https://nuget.privaterepo.com/nuget/"...注意协议的差异。

所以......我正在尝试出站重写service xml:basewith的值https。具有以下内容:

<configuration>
  <system.webServer>
    <rewrite>
      <outboundRules rewriteBeforeCache="true">
        <rule name="Rewrite Product Outbound" preCondition="IsHTML" enabled="true" stopProcessing="true">
          <match filterByTags="A, CustomTags" customTags="NuGet service base" pattern="http://" ignoreCase="true" />
          <action type="Rewrite" value="https://{HTTP_HOST}{REQUEST_URI}" />
        </rule>
        <preConditions>
          <preCondition name="IsHTML" logicalGrouping="MatchAny">
            <add input="{RESPONSE_CONTENT_TYPE}" pattern="^application/xml" />
            <add input="{RESPONSE_CONTENT_TYPE}" pattern="^application/atom+xml" />
          </preCondition>
        </preConditions>
        <customTags>
          <tags name="NuGet service base">
            <tag name="service" attribute="xml:base" />
            <tag name="feed" attribute="xml:base" />
          </tags>
        </customTags>
      </outboundRules>
    </rewrite>
  </system.webServer>
</configuration>

我遇到的绊脚石是写作<tag name="service" attribute="xml:base" />,这似乎是正确的。但是,它不会用https协议重写值。

我已经使用 NuGet 服务器和使用相同输出的测试项目对此进行了测试。xml:base如果我更改为base重写规则,则使用测试项目将起作用。

4

0 回答 0