-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.html
202 lines (165 loc) · 6.54 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
<!doctype html>
<html>
<head>
<link href='https://fonts.googleapis.com/css?family=Open+Sans:400italic,700italic,400,700|Average' rel='stylesheet' type='text/css'>
<link rel="canonical" href="http://konklone.io/cdns-to-https/" />
<!-- use jQuery 1.X, which supports old browsers too -->
<script src="js/jquery-1.11.2.min.js"></script>
<script>window._cors = true;</script>
<!--[if lte IE 9]>
<script>window._cors = false</script>
<![endif]-->
<script>
window.loaded = {};
// Called *by* the loaded scripts themselves.
function done(name) {
loaded[name] = true;
$(".test." + name).addClass("success");
}
// Called after a delay, when inferred to have failed.
function failed(name) {
$(".test." + name).addClass("failure");
}
</script>
<style>
body {
padding: 20px;
font-family: Open Sans, Arial, sans-serif;
width: 90%;
}
h2 {margin-top: 0; padding: 0;}
.test {
background-color: #ddd;
width: 100%;
padding: 20px 10px;
margin: 20px 0;
}
.test::before {content: "TESTING."; text-transform: uppercase; padding-right: 10px; font-weight: normal;}
.test.success::before {content: "PASSED."; font-weight: bold;}
.test.failure::before {content: "FAILED."; font-weight: bold;}
.test.success {background-color: #0c0;}
.test.failure {background-color: #c00;}
</style>
</head>
<body>
<h2>Moving CDNs to HTTPS</h2>
<p>
Testing the effects of redirecting HTTP -> HTTPS for assets hosted by third party CDNs (e.g. <code>code.jquery.com</code> or <code>ajax.googleapis.com</code>).
</p>
<p>
<strong><a href="https://github.com/konklone/cdns-to-https#moving-cdns-to-https">Read the background, results, and conclusions.</a></strong>
</p>
<p>
This page must be hosted on an insecure (<code>http://</code>) connection to properly test the redirect, otherwise mixed-content blocking will interfere with the tests.
</p>
<ul>
<li><code>plain-cdn.konklone.io</code> serves only HTTP.</li>
<li><code>cdn.konklone.io</code> redirects HTTP to HTTPS (no Strict Transport).</li>
<li><code>www.cdn.konklone.io</code> redirects HTTP to HTTPS (with Strict Transport set).</li>
<li>Fetched resources are not cached.</li>
</ul>
<p>
Code and server config is <a href="https://github.com/konklone/cdns-to-https">on GitHub</a>. Test by <a href="https://twitter.com/konklone">Eric Mill</a>, who wants <a href="https://github.com/konklone/cdns-to-https#conclusion-cdns-should-redirect-to-https">all CDNs to force redirects from HTTP to HTTPS</a>.
</p>
<div class="test script_control_https">
<strong>Control:</strong> <script> tag for HTTPS asset:
<code>
<a href="https://cdn.konklone.io/js/script_control_https.js">
https://cdn.konklone.io/js/script_control_https.js
</a>
</code>
</div>
<div class="test script_control_http">
<strong>Control:</strong> <script> tag for HTTP asset.
<code>
<a href="http://plain-cdn.konklone.io/js/script_control_http.js">
http://plain-cdn.konklone.io/js/script_control_http.js
</a>
</code>
</div>
<div class="test script_redirect">
<strong>Test:</strong> <script> tag for HTTP->HTTPS asset redirect.
<code>
<a href="http://cdn.konklone.io/js/script_redirect.js">
http://cdn.konklone.io/js/script_redirect.js
</a>
</code>
</div>
<div class="test cors cors_control_https">
<strong>Control:</strong> CORS GET request for HTTPS asset.
<code>
<a href="https://cdn.konklone.io/js/cors_control_https.js">
https://cdn.konklone.io/js/cors_control_https.js
</a>
</code>
</div>
<div class="test cors cors_control_http">
<strong>Control:</strong> CORS GET request for HTTP asset.
<code>
<a href="http://plain-cdn.konklone.io/js/cors_control_http.js">
http://plain-cdn.konklone.io/js/cors_control_http.js
</a>
</code>
</div>
<div class="test cors cors_redirect">
<strong>Test:</strong> CORS GET request for HTTP->HTTPS asset redirect.
<code>
<a href="http://cdn.konklone.io/js/cors_redirect.js">
http://cdn.konklone.io/js/cors_redirect.js
</a>
</code>
</div>
<div class="test cors cors_hsts">
<strong>Test:</strong> CORS GET request for HTTP->HTTPS asset with <a href="https://developer.mozilla.org/en-US/docs/Web/Security/HTTP_strict_transport_security">HSTS</a>.
<code>
<a href="http://www.cdn.konklone.io/js/cors_hsts.js">
http://www.cdn.konklone.io/js/cors_hsts.js
</a>
</code>
</div>
<script>
var cachebuster = "?" + new Date().getTime().toString();
if (!window._cors) $(".cors").hide();
// control: <script> loading of .js on HTTPS
$.getScript("https://cdn.konklone.io/js/script_control_https.js" + cachebuster);
// control: <script> loading of .js on HTTP
$.getScript("http://plain-cdn.konklone.io/js/script_control_http.js" + cachebuster);
// test: <script> loading of .js on HTTP->HTTPS redirect (no HSTS)
$.getScript("http://cdn.konklone.io/js/script_redirect.js" + cachebuster);
if (window._cors) {
// control: CORS loading of HTTPS
$.get("https://cdn.konklone.io/js/cors_control_https.js" + cachebuster);
// control: CORS loading of HTTP
$.get("http://plain-cdn.konklone.io/js/cors_control_http.js" + cachebuster);
// test: CORS on HTTP->HTTPS redirect
$.get("http://cdn.konklone.io/js/cors_redirect.js" + cachebuster);
// test: CORS with HSTS set
// this fetches an HTTPS version first, to guarantee that the header is seen. on return, it triggers a second function which then asks for the http:// version (and hopefully does an internal redirect and goes right for the https:// version).
function hsts_set() {
$.get("http://www.cdn.konklone.io/js/cors_hsts.js" + cachebuster);
}
$.get("https://www.cdn.konklone.io/js/cors_hsts_pre.js" + cachebuster);
}
// after 10s, if the tests aren't successes, deem them failures
setTimeout(function() {
var names = [
'script_control_https', 'script_control_http', 'script_redirect',
'cors_control_https', 'cors_control_http', 'cors_redirect',
'cors_hsts'
];
for (var i=0; i<names.length; i++)
if (!loaded[names[i]]) failed(names[i]);
}, 10 * 1000)
</script>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-252618-16', 'konklone.io');
ga('set', 'forceSSL', true);
ga('set', 'anonymizeIp', true);
ga('send', 'pageview');
</script>
</body>
</html>