IIS URL書き換え: @import in section?

IIS URL書き換え: @import in section?

私はJetBrains TeamCity(ポート81でTomCatを使用)をIIS 7の背後に置こうとしています。http://www.example.com/teamcity/プロキシされるhttp://myserver:81/TeamCity が要素に @import を出力することを除いて、ほぼ動作していると思います。<style>これに対処するための送信ルールを定義する方法がわかりません。

これに対処するために URL を書き換えるにはどうすればよいですか?

または、代わりに、TeamCity に代替仮想ディレクトリについて教え、すべてに のプレフィックスを付けることもできますか/teamcity?

あるいは、もっと別の言い方をすると、TeamCity を IIS 7.5 の背後に配置するより良い方法はありますか?

答え1

アップデート:以下は完全には機能しません。一部の Javascript に問題があり、ログアウト リダイレクトが壊れています。

オプション:

  1. をリッスンしている Tomcat インストールで TeamCity をホストする/teamcityと、アウトバウンド ルールは不要になります。私はこれを Drupal インストールで動作させています。
  2. 代わりにリダイレクトしますteamcity.example.com(仮想ディレクトリはありません)。この手順の例他の場所。これには、いくつかの DNS CNAME とワイルドカード証明書 (外部アクセスに HTTPS を使用する場合) が必要になります。

その他の指示は後世のためにここに残しておきます...

を設定することで、テキストの任意の部分を書き換えるように URL 書き換えを構成できますfilterByTags="None"

つまり、次のようになりますC:\Inetpub\wwwroot\web.config:

<configuration>
  <system.webServer>
    <rewrite>
      <rules>
        <!-- Anything to http://www.example.com/teamcity/ should be
             rewritten to http://teamcity:81/ -->
        <rule name="TeamCity (/teamcity)">
          <match url="^teamcity/(.*)" />
          <serverVariables>
            <!-- URL Rewrite can't deal with Encoding: gzip; turn that off. -->
            <set name="HTTP_ACCEPT_ENCODING" value="" />
          </serverVariables>
          <action type="Rewrite"
                  url="http://teamcity:81/{R:1}" />
        </rule>
      </rules>

これがインバウンドルールです。アウトバウンドルールは 3 つあります。

      <outboundRules>

ログインリダイレクト:

        <!-- 302 Redirects (for the login page, e.g.) need to be rewritten. -->
        <rule name="Teamcity (/teamcity) - Redirect" preCondition="IsRedirect">
          <match serverVariable="RESPONSE_LOCATION"
                 pattern="http://[^/]+/(.*)" />
          <action type="Rewrite"
                  value="http://www.example.com/teamcity/{R:1}" />
        </rule>

通常の HTML 書き換え:

        <!-- Links in HTML need to be rewritten. -->
        <rule name="TeamCity (/teamcity) - HTML" preCondition="IsHTML">
          <!-- I've ellided the other tag types here; you might want them. -->
          <match filterByTags="A, ..."
                 pattern="^(.*)" />
          <action type="Rewrite"
                  value="http://www.example.com/teamcity/{R:1}" />
        </rule>

CSS ファイルの @import:

        <!-- TeamCity uses @import for styles; fix that. -->
        <rule name="TeamCity (/teamcity) - Style" preCondition="IsHTML">
          <match filterByTags="None" pattern="@import &quot;/" />
          <action type="Rewrite" value="@import &quot;/teamcity/" />
        </rule>

いくつかの前提条件:

        <preConditions>
          <preCondition name="IsRedirect">
            <add input="{RESPONSE_STATUS}" pattern="302" />
          </preCondition>
          <preCondition name="IsHTML">
            <add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
          </preCondition>
        </preConditions>
      </outboundRules>

    </rewrite>
  </system.webServer>
</configuration>

動作するように見えますが、他に何か見つかった場合は戻ってこの回答を更新します。

関連情報