Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Open.window() Document.referrer from HTTPS site to HTTP site empty

Site1.com offers the possibility to open Site2.com in another window through a button. Site2.com checks document.referrer. As long as Site1.com and Site2.com are using HTTP everything works fine, and the referrer attribute contains the URL of Site1.com.

If Site1.com runs with SSL (https://site1.com), but Site2.com doesn't, the referrer is suddenly empty.

JS Client code on https://site1.com

window.open("http://site2.com", "mySite2.com")

The Site2.com checks the referrer in the JS client code by:

document.referrer

Which turns out to be empty.

My Question: Is this a Javascript problem or an Nginx problem? Why is the referrer empty when using HTTPS on Site1.com ?

Again, if both sites are using HTTP, everything works just fine. The referrer just doesn't get passed on the Site2.com is Site1.com is using HTTPS.

like image 349
dh1tw Avatar asked Aug 23 '26 17:08

dh1tw


2 Answers

Neither. It is browsers security policy. They do not send referrer when go from secure site to non-secure.

like image 113
Alexey Ten Avatar answered Aug 25 '26 07:08

Alexey Ten


According to HTTP 1.1 protocol.

Clients SHOULD NOT include a Referer header field in a (non-secure) HTTP request if the referring page was transferred with a secure

Here is the policy.

You can not referrer on https to site using http. Referrer will get from

https to https or http to https.

like image 41
Musakkhir Sayyed Avatar answered Aug 25 '26 07:08

Musakkhir Sayyed