IIS Rewrite 2.0 CustomTags with namespaced attribute

363 views Asked by At

I'm hosting a private NuGet server which is behind a load balancer. The load balancer accepts ssl traffic (442) and forwards to port 80 on the web server.

NuGet looks to be detecting the requesting protocol and returns a base href with http vs. https.

So requests for https://nuget.privaterepo.org are returned with the following content:

<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>

This should render <service xml:base="http://nuget.privaterepo.com/nuget/"... as <service xml:base="https://nuget.privaterepo.com/nuget/"... notice the difference in protocol.

So... i'm attempting to outbound rewrite the value of service xml:base with https. with the following:

<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>

where i've hit a stumbling block is writing <tag name="service" attribute="xml:base" /> which seems correct. however, it is not rewriting the value with the https protocol.

I've tested this with the NuGet server and a test project using the same output. using the test project if i change xml:base to base the rewrite rule will work.

0

There are 0 answers