11

IIS7 と Application Request Routing 拡張機能を使用して、Apache で実行されている Subversion へのリバース プロキシとして機能しています。

プロキシは正常に動作し、サーバーを探索したり、「チェックアウト」を実行したりできます。ただし、通常は ASP.NET で禁止されているファイル (.cs、.csproj など) を参照できません。ASP.NET が関係しないファイル (.txt など) は問題ありません。

グローバルな web.config を編集して、これらのファイルの Forbidden ハンドラー マッピングを削除しようとしましたが、違いはないようです。すべてのファイル拡張子をレンダリングできるようにしながら、IIS7 の URL 書き換えモジュールを機能させる方法はありますか?

4

4 に答える 4

16

IIS7 には、ファイル拡張子を制限するセキュリティ セクションを含むapplicationHost.configファイルがあります。

<requestFiltering>
  <fileExtensions allowUnlisted="true" applyToWebDAV="true">
    <add fileExtension=".cs" allowed="false" />
    <add fileExtension=".csproj" allowed="false" />
    <add fileExtension=".vb" allowed="false" />
    <add fileExtension=".vbproj" allowed="false" />
    ....
  </fileExtensions>

詳しくは:

http://learn.iis.net/page.aspx/143/how-to-use-request-filtering/

サイトの web.config に同様のセクションを追加し、<clear />ノードを使用してすべての拡張機能を削除しました。.cs、.csproj ファイルなどを提供できるようになりましたが、.config ファイルはまだ提供できません。

編集: hiddenSection ノードを削除すると、web.config ファイルについてもこれが修正されました。ここに私のローカル web.config ファイルがあります:

<system.webServer>
  <security>
    <requestFiltering>
      <fileExtensions allowUnlisted="true" applyToWebDAV="true">
        <clear />
      </fileExtensions>
      <verbs allowUnlisted="true" applyToWebDAV="true" />
      <hiddenSegments applyToWebDAV="true">
        <clear />
      </hiddenSegments>
    </requestFiltering>
  </security>
</system.webServer>
于 2009-09-27T13:34:18.473 に答える
4

次のように web.config で動作するようになりました。

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="ReverseProxyInboundRule1" stopProcessing="true">
                    <match url="(.*)" />
                    <conditions>
                        <add input="{CACHE_URL}" pattern="^(https?)://" />
                    </conditions>
                    <action type="Rewrite" url="{C:1}://localhost:8080/{R:1}" />
                </rule>
            </rules>
            <outboundRules>
                <rule name="ReverseProxyOutboundRule1" preCondition="ResponseIsHtml1">
                    <match filterByTags="A, Form, Img" pattern="^http(s)?://localhost:8080/(.*)" />
                    <action type="Rewrite" value="http{R:1}://svn.mysite.com/{R:2}" />
                </rule>
                <preConditions>
                    <preCondition name="ResponseIsHtml1">
                        <add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
                        <add input="{RESPONSE_CONTENT_ENCODING}" pattern="[^(gzip)]" />
                    </preCondition>
                </preConditions>
            </outboundRules>
        </rewrite>
        <security>
        <requestFiltering>
          <fileExtensions allowUnlisted="true" applyToWebDAV="true">
            <clear />
          </fileExtensions>
          <verbs allowUnlisted="true" applyToWebDAV="true" />
          <hiddenSegments applyToWebDAV="true">
            <clear />
          </hiddenSegments>
        </requestFiltering>
      </security>
    </system.webServer>
</configuration>
于 2012-11-25T05:01:19.330 に答える
1

Paul Stovell の回答に加えて、ダブル エスケープを有効にすることをお勧めします。ファイル名に「+」文字を含むファイルを取得するときにエラーが発生しました。ダブルエスケープはこの問題を解消します:

    <configuration>
        <system.webServer>
            <rewrite>
                <rules>
                    <rule name="SVNIn" stopProcessing="false">
                        <match url="(.*)" />
                        <action type="Rewrite" url="http://localhost:8082/svn/{R:1}" />
                    </rule>
                </rules>
            </rewrite>
            <security>
                <requestFiltering allowDoubleEscaping="true">
                    <fileExtensions allowUnlisted="true" applyToWebDAV="true">
                        <clear />
                    </fileExtensions>
                    <verbs allowUnlisted="true" applyToWebDAV="true" />
                    <hiddenSegments applyToWebDAV="true">
                        <clear />
                    </hiddenSegments>
                </requestFiltering>
            </security>
        </system.webServer>
    </configuration>
于 2021-02-25T11:03:49.377 に答える