且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Azure Web应用程序无法将代理反向到Wordpress网站

更新时间:2022-12-20 20:49:43

使用 xdt:Transform ="InsertIfMissing" 来设置具有相同标记名的同一父对象的多个子元素(< add> ),您还需要使用 xdt:Locator ="Match(name)" ,否则XDT系统只会先插入 < add> 元素.

When using xdt:Transform="InsertIfMissing" to set multiple child-elements of the same parent with the same tag-name (<add>) you need to also use xdt:Locator="Match(name)", otherwise the XDT system will only insert the first <add> element.

因此,在您的情况下,XDT系统仅插入< add name ="HTTP_X_USE_HTTPS"/> ,但不会复制其他元素,因为已经存在一个< add/> 元素.

So in your case, the XDT system is only inserting <add name="HTTP_X_USE_HTTPS" /> but won't copy the other elements because there's already an <add /> element present.

(我认为如果源转换文档指定多个 Insert InsertIfMissing 元素而没有 xdt:Locator )

(I feel that XDT should be improved throw an error if a source transform document specifies multiple Insert or InsertIfMissing elements without a xdt:Locator)

因此将您的 applicationHost.xdt 更改为此:

<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">  
    <system.webServer>
        <proxy xdt:Transform="InsertIfMissing" enabled="true" preserveHostHeader="false" reverseRewriteHostInResponseHeaders="false" />
        <rewrite>
            <allowedServerVariables>
                <add name="HTTP_X_USE_HTTPS"                xdt:Transform="InsertIfMissing" xdt:Locator="Match(name)" />
                <add name="HTTP_X_ORIGINAL_HOST"            xdt:Transform="InsertIfMissing" xdt:Locator="Match(name)" />
                <add name="HTTP_X_UNPROXIED_URL"            xdt:Transform="InsertIfMissing" xdt:Locator="Match(name)" />
                <add name="HTTP_X_ORIGINAL_ACCEPT_ENCODING" xdt:Transform="InsertIfMissing" xdt:Locator="Match(name)" />
                <add name="HTTP_ACCEPT_ENCODING"            xdt:Transform="InsertIfMissing" xdt:Locator="Match(name)" />
            </allowedServerVariables>
        </rewrite>
    </system.webServer>
</configuration>