Chendi Xue

I am linux software engineer, currently working on Spark, Arrow, Kubernetes, Ceph, c/c++, and etc.

Lessons Learned by ajax request http from https

10 Oct 2018 » Website


I am building my jekyll blog portal recently on github, and since github is static, while I still want to add some cool features who can not be simply implemented by javascript inside browser, I came up this thought, can I ajax to my amazon EC2 virtual machine to handle some dynamic requests?

And I have this image in my mind. From-Ajax-HTTP-From-HTTPS

Then let’s consider this idea for a bit:

Exists Conditions:

  • github is now using https protocol for hosting page site, which means my browser is a https client.
  • It’s easy to host a http server on EC2.

[IDEA 1]

Then I came up with a very naive idea, Is it possible to ajax to a http website from https client?

The answer is NO! Because to request http site data from https downgraded this https website’s security level. Reference

A live example, press to test

function get_subscribe_status () {
	$.ajax({
		url: "http://ec2-18-191-213-11.us-east-2.compute.amazonaws.com/subscribe_status",
		type: 'get',
		dataType: 'text'
	}).done(function(data) {
		$("div.subscribe-block-status").text(data);