2016-11-29 191 views
2

我已經通過Bitnami安裝了Redmine。 現在運行的Apache服務器上IIS URL用虛擬目錄cookie重寫?

http://localhost:81/redmine 

我現在想在IIS將這一作爲反向代理。 所以在IIS中,我創建應用程序http://localhost/redmine

,現在我想反向代理從http://localhost:81/redminehttp://localhost/redmine

所以我設置了URL重寫如下。
似乎工作,除了登錄。該cookie不會被重寫。 這是因爲redmine位於Apache服務器上的虛擬目錄redmine,但將cookie設置爲http://localhost:81而不是http://localhost:81/redmine

如何修改URL重寫,以便cookie也被重寫?

</system.web> 
    <system.webServer> 
     <httpRedirect enabled="false" destination="http://localhost:81/redmine/" childOnly="false" /> 
     <rewrite> 
      <rules> 
       <rule name="redmine" patternSyntax="Wildcard" stopProcessing="true"> 
        <match url="*" /> 
        <!-- 
        <conditions> 
        <add input="{HTTP_COOKIE}" pattern="_redmine_session=([0-9.a-zA-Z]+)" /> 
        </conditions> 
       --> 
       <!-- 
       <conditions> 
        <add input="{HTTP_COOKIE}" pattern="_redmine_session=(.*?);" /> 
       </conditions> 
       --> 
        <action type="Rewrite" url="http://localhost:81/redmine/{R:0}" /> 
       </rule> 
      </rules> 
     </rewrite> 
    </system.webServer> 

回答

2

您錯過了一件事: URL重寫模塊是一個URL重寫模塊。
這不是一個反向代理模塊。

因此僅從http://localhost/virt_dir_xhttp://localhost:3000/virt_dir_y添加規則是不夠的。

您還需要重新編寫相反方向: http://localhost:3000/virt_dir_y。到http://localhost/virt_dir_x

看到this

<system.webServer> 
    <rewrite> 
     <rules> 
      <rule name="ReverseProxyInboundRule1" stopProcessing="true"> 
       <match url="(.*)" /> 
       <action type="Rewrite" url="http://http://127.0.0.1:3000/{R:1}" /> 
      </rule> 
     </rules> 
     <outboundRules> 
      <rule name="ReverseProxyOutboundRule1" preCondition="ResponseIsHtml1"> 
       <match filterByTags="A, Form, Img" pattern="^http(s)?://http://127.0.0.1:3000/(.*)" /> 
       <action type="Rewrite" value="http{R:1}://localhost/{R:2}" /> 
      </rule> 
      <preConditions> 
       <preCondition name="ResponseIsHtml1"> 
        <add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" /> 
       </preCondition> 
      </preConditions> 
     </outboundRules> 
    </rewrite> 
</system.webServer> 

這裏假設你有虛擬目錄 「管理平臺」 這兩個應用程序。