0

IIS でホストされている ASP.NET アプリケーションの "web.config" で、次の書き換え規則を構成しました。

    <rewrite>
        <rules>
            <rule name="setappname">
                <match url=".*" />
                <serverVariables>
                    <set name="CONTAINER_APP_NAME" value="desiredValue" />
                </serverVariables>
            </rule>
        </rules>
    </rewrite>

「applicationHost.config」には、次のスニペットがあります。

    <sites>
        <site name="mysite" id="1" serverAutoStart="true">
            <application path="/" applicationPool=".NET v4.5">
                <virtualDirectory path="/" physicalPath="c:\mysite" />
            </application>
            <bindings>
                <binding protocol="http" bindingInformation="*:80:" />
            </bindings>
            <logFile directory="c:\iislog" period="MaxSize" truncateSize="4294967295">
                <customFields>
                    <add logFieldName="x-forwarded-for" sourceName="X-Forwarded-For" sourceType="RequestHeader" />
                    <add logFieldName="container-app" sourceName="CONTAINER_APP_NAME" sourceType="ServerVariable" />
                </customFields>
            </logFile>
            <applicationDefaults preloadEnabled="true" />
        </site>
    </sites>

<system.webServer>
    <rewrite>
        <allowedServerVariables>
            <add name="CONTAINER_APP_NAME" />
        </allowedServerVariables>
    </rewrite>
</system.webServer>

パスが「/」で終わる場合を除いて、これは正常に機能します (ログに 2 つのカスタム フィールドが表示されます) (例:/または/APath/)。そのような場合、container-appフィールドの値 (サーバー変数を使用) は常に "-" です。例えば:

$ curl --silent --output /dev/null -H "X-Forwarded-For:10.3.2.12" http://localhost/APath/

収量:

2019-12-02 20:47:32 172.29.152.165 GET /APath/ - 80 - 192.168.7.4 curl/7.67.0 - 200 0 0 121 10.3.2.12,+::1 -

一方:

$ curl --silent --output /dev/null -H "X-Forwarded-For:10.3.2.12" http://localhost/home.aspx

収量:

2019-12-02 20:50:17 172.29.152.165 GET /home.aspx - 80 - 192.168.7.4 curl/7.67.0 - 200 0 0 63 10.3.2.12,+::1 desiredValue

失敗したリクエストのトレースを有効にして、おそらく書き換えルールがそれらのパスを取得していないかどうかを確認しましたが、ルールがパスと一致し、サーバー変数が目的の値に設定されていることを確認できました。

これをトラブルシューティングするために他に何かできることはないかと思います。そのようなパスが適切にログに記録されないのはなぜですか?

4

1 に答える 1