2016-11-04 48 views
0

我們正在將我們的聯邦政府網站移至https-only。我們收到了來自我們鏈接到的網站的投訴,即當這些網站僅使用http時,我們的推薦人已經消失。這是因爲https-> http降級默認情況下隱藏了引用者。<meta name ='referrer'> works,Referrer-Policy header not

我們正在嘗試使用HTTP請求標頭Referrer-Policy: origin-when-cross-origin,但它似乎不起作用。但是,將<meta name='referrer' content='origin-when-cross-origin'>確實爲大多數瀏覽器提供了正確的行爲。

我們設置標題:

<pre> 
 
$ curl -sI https://www.ncbi.nlm.nih.gov/corecgi/tests/testref.cgi 
 
HTTP/1.1 200 OK 
 
Date: Fri, 04 Nov 2016 20:53:38 GMT 
 
Server: Apache 
 
Strict-Transport-Security: max-age=31536000; includeSubDomains; preload 
 
Content-Security-Policy: upgrade-insecure-requests 
 
Referrer-Policy: origin-when-cross-origin 
 
Content-Security-Policy-Report-Only: default-src https:; script-src https: 'unsafe-inline' 'unsafe-eval'; font-src https: data:; img-src https: data:; style-src https: 'unsafe-inline'; report-uri https://www.ncbi.nlm.nih.gov/corecgi/csp/csp.cgi 
 
Referrer-Policy: origin-when-cross-origin 
 
Access-Control-Allow-Methods: POST, GET, PUT, OPTIONS, PATCH, DELETE 
 
Access-Control-Allow-Origin: 
 
Access-Control-Allow-Credentials: true 
 
Access-Control-Allow-Headers: X-Accept-Charset,X-Accept,Content-Type,X-Requested-With,NCBI-SID,NCBI-PHID 
 
Content-Type: text/html 
 
Vary: Accept-Encoding 
 
X-UA-Compatible: IE=Edge 
 
X-XSS-Protection: 1; mode=block 
 
</pre>

但是,這頭不起作用:

試試這個:https://www.ncbi.nlm.nih.gov/corecgi/tests/testref.cgi 注意,https-> HTTP降級鏈接發送一個空白標題

然而,它的<meta> e lement給出了期望的行爲: https://www.ncbi.nlm.nih.gov/corecgi/tests/testref.cgi?meta=true

有沒有其他人有,並修復這個問題?

+0

我注意到你要發送的報頭的兩倍。嘗試發送一次,看看是否改變了行爲? – Konklone

+0

您正在測試什麼瀏覽器+版本?只有Chrome 56或更高版本支持Referrer-Policy標頭(除非您在早期版本中設置了特殊標誌)。 – Emily

回答

2

看起來Chrome是約而至,但不相當,但,支持引薦-策略標題:

它將在Chrome 56是可用穩定。自從Chrome 53以來,它一直落後於旗幟,所以你可以使用--enable-experimental-web-platform-features來運行Chrome來試用它。

引薦,政策支持頭船將在Firefox 50:

+0

謝謝,剛剛得到這個建議。 – elucify