Mat Kay
Mat Kay

Reputation: 518

how do I then make the page secure via https when using a cdn?

My web page uses relative urls internally but also I use direct links to googlemaps and jquery.

how do I then make the page secure for https?

Thanks,

Mat

Upvotes: 0

Views: 566

Answers (2)

LeonardChallis
LeonardChallis

Reputation: 7783

You could check whether you are currently using HTTPS or HTTP and outputting the correct URL depending on that, but the best thing to do is to omit the protocol altogether, and the colon, which will leave the browser to use the same as what that page is being served from. For instance let's say you has this URL:

http://mycdn.com/project/version.script.js

In your code you would just use:

//mycdn.com/project/version.script.js

i.e.:

< script src="//mycdn.com/project/version.script.js">< /script>

Your HTTPS pages would grab https://mycdn.com/project/version.script.js whereas your http pages would use http://mycdn.com/project/version.script.js

Upvotes: 5

Rowlf
Rowlf

Reputation: 1762

You'll just need to point to the HTTPS versions of the external assets you're loading to make the entire page secure.

jQuery's Microsoft CDN supports SSL: https://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.1.min.js

(source: http://docs.jquery.com/Downloading_jQuery#CDN_Hosted_jQuery)

Google Maps can also be used over an SSL connection for free:

To load the Maps API v3 over HTTPS, the API must be loaded from the hostname maps-api-ssl.google.com. For the Static Maps API and Web Services, please use maps.googleapis.com.

(source: http://googlegeodevelopers.blogspot.com.au/2011/03/maps-apis-over-ssl-now-available-to-all.html)

Upvotes: 1

Related Questions