2017-09-06 49 views
3

我試圖通過使用Azure網站設置反向代理,大致跟在this guide之後,它解釋瞭如何在此類網站上修改ApplicationHost.config - 但它不起作用爲了我。Azure應用服務applicationHost.xdt似乎沒有效果

我已經有這個applicationHost.xdt:

<?xml version="1.0"?> 
<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_ORIGINAL_HOST" xdt:Transform="InsertIfMissing" /> 
       <add name="HTTP_X_UNPROXIED_URL" xdt:Transform="InsertIfMissing" /> 
       <add name="HTTP_X_ORIGINAL_ACCEPT_ENCODING" xdt:Transform="InsertIfMissing" /> 
       <add name="HTTP_ACCEPT_ENCODING" xdt:Transform="InsertIfMissing" /> 
      </allowedServerVariables> 
     </rewrite> 
    </system.webServer> 
</configuration> 

我把它放在site目錄我的web應用程序。

的變換似乎得到執行(從轉換日誌):

2017-09-06T12:12:20 StartSection Executing InsertIfMissing (transform line 8, 50) 
2017-09-06T12:12:20 on /configuration/system.webServer/rewrite/allowedServerVariables/add 
2017-09-06T12:12:20 Applying to 'allowedServerVariables' element (no source line info) 
2017-09-06T12:12:20 EndSection Done executing InsertIfMissing 

我確實有這些塊中的四個。

我仍然得到500s設置與重寫頭。詳細的錯誤信息包含:

<h3>HTTP Error 500.50 - URL Rewrite Module Error.</h3> 
<h4>The server variable &quot;HTTP_X_UNPROXIED_URL&quot; is not allowed to be set. Add the server variable name to the allowed server variable list.</h4> 

不知道該怎麼做。有任何想法嗎?

+1

請從https://github.com/projectkudu/kudu/wiki/Azure-Site-Extensions#understanding-what-c​​ould-go-wrong-with-xdt-transforms開始,並確定您的問題是否存在第二桶或第三桶。 –

+0

我已經掌握了該資源 - 謝謝。我不知道如何看到最終的'applicationhost.config'。 – John

回答

2

調查這些問題的關鍵是要確定問題是轉換沒有做正確的事情,還是applicationhost.config沒有按預期工作。

您可以從Kudu控制檯檢查D:\local\Config中生成的applicationhost.config。

有關詳情,請參閱this page

+0

我已經檢查了幾次,併發布applicationHost.xdt在我的主插槽上工作,但沒有轉換髮生在我的開發插槽。 xdt是一樣的,我將它放在相同的位置,但即使重新啓動應用程序後也沒有創建轉換日誌文件夾。我得到的500是訪問被拒絕,試圖訪問我的web.config的URL Rewrite規則中的標題。我在想,如果這是一個雞和蛋的事情,變形不會發生,因爲它發生在管道後面比URL重寫評估? – Sentinel

+0

@Sentinel會提出一個新問題,因爲你的案例看起來更具體。隨意從這裏鏈接到它。 –

+0

你好[大衛Ebbo](https://stackoverflow.com/users/111888/david-ebbo) - 你偶然有任何解決方案[重寫規則到IIS的HTTPS重定向到HTTP導致null HttpContext.Request.ContentType ](https://stackoverflow.com/questions/48871977/rewrite-rule-to-iis-for-https-redirect-to-http-causes-null-httpcontext-request-c)? – ttugates

相關問題