2009-09-27 36 views
8

我使用IIS7和應用程序請求路由擴展充當在Apache上運行的Subversion的反向代理。IIS7和ARR作爲Subversion的反向代理

該代理工作正常,我能夠探索服務器,甚至執行「檢查」。但是,我無法瀏覽ASP.NET通常禁止的文件,例如.cs,.csproj等。 ASP.NET不關心的文件 - 比如.txt - 很好。

我試圖編輯全局web.config,以刪除這些文件的Forbidden處理程序映射,但它似乎沒有什麼區別。有沒有辦法允許IIS7中的URL重寫模塊工作,同時允許渲染所有文件擴展名?

回答

13

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> 
+0

是的,這爲我工作。 +1 – 2011-08-05 18:11:47

+0

這就是答案。謝謝! – Alexandr 2017-04-07 12:10:43

3

我得到了它與我的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>