2015-12-17 51 views
1

我發佈這更多作爲標題問題的答案,因爲我們已經與Cloudflare的有用的支持團隊溝通後解決了它。自從做研究時,我們無法找到解決方案,這可能會幫助其他人!CloudFlare靈活的SSL重定向循環在ASP.Net網站

當啓用CloudFlare的靈活SSL並且要http重定向到https使用方法,如How to force HTTPS using a web.config file描述,你將很有可能在重定向循環結束的所有請求。

您可以選擇通過CloudFlare的頁面規則使用頁面規則,如https://support.cloudflare.com/hc/en-us/articles/200170536-How-do-I-redirect-all-visitors-to-HTTPS-SSL-中所述,但在我們的情況下仍然會在網站內留下一些非HTTPS請求,導致網站不安全。

回答

1

如可以相同的CloudFlare支持文章https://support.cloudflare.com/hc/en-us/articles/200170536-How-do-I-redirect-all-visitors-to-HTTPS-SSL-內可以看出,CloudFlare的追加CF-訪客HTTP標頭所解釋:

CF-Visitor: {"scheme":"https"} 

出於這個原因,這爲我們工作的相應的web.config <rewrite>片斷是如下:

<rewrite> 
    <rules> 
    <rule name="Redirect to https" stopProcessing="true"> 
     <match url="(.*)" /> 
     <conditions> 
      <add input="{HTTP_CF_VISITOR}" pattern="(.*)https(.*)" ignoreCase="true" negate="true" /> 
     </conditions> 
     <action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" appendQueryString="false" redirectType="Permanent" /> 
    </rule> 
    </rules> 
</rewrite>