Repository navigation
GitHub pages redirect from https to http #289
Description
GitHub pages (gh-pages) now have partial HTTPS support (see #156), at least on the github.io domain, but this support is not fully integrated into gh-pages servers.
Issue
GitHub's static pages' Varnish servers redirect some https:// URLs to http://
E.g., when the user requests a URL that points to a directory, but does not use a trailing slash (see Example section below)
Solution
The redirect's protocol should match the request's protocol.
Example
I have a gh-pages repository at https://github.com/linguistics/tls (a conference; no relation to Transport Layer Security), and URLs like the following work as expected:
However, when requesting the following URLs, they do not redirect to the page above, but to http://linguistics.github.io/tls/2014tls/
- https://linguistics.github.io/tls/2014tls
- https://linguistics.github.com/tls/2014tls/
- https://linguistics.github.com/tls/2014tls
To reproduce
The results above can be confirmed in the browser or on the command line:
$ curl -s -I https://linguistics.github.io/tls/2014tls | grep Location
Location: http://linguistics.github.io/tls/2014tls/
$ curl -s -I https://linguistics.github.com/tls/2014tls/ | grep Location
Location: http://linguistics.github.io/tls/2014tls/
$ curl -s -I https://linguistics.github.com/tls/2014tls | grep Location
Location: http://linguistics.github.io/tls/2014tls
Comments
The *.github.io wildcard certificate, #156, was the hard part (thanks GitHub!). This fix should be easy.
Activity
apatrida commentedon Dec 8, 2014
The redirect also affects when you put a CDN in front of Github pages. One URL error and you end up on the wrong site, and have to build into your pages to redirect back to the CDN in that case. But then it is hard to test on both Github pages and a live CDN at the same time. The redirect should stay on the same domain to add the trailing "/"
chbrown commentedon Dec 8, 2014
That reminds me that I got a response regarding this issue from "Jamie Murai (GitHub Staff)" on 2014-11-06, which I've pasted below in its entirety:
dentarg commentedon Feb 15, 2015
I also emailed GitHub support about this issue and received the following response 2015-02-03:
z3ntu commentedon Jul 18, 2015
Any news yet?
cben commentedon Jul 21, 2015
The *.github.com redirects happen for all pages, not just directories:
But that's pretty OK, we just shouldn't use the grandfathered .com addresses (they're also slower), use .io everywhere.
The directories on .io redirect is truly a problem.
Updated links to fix github https redirecting issue. See isaacs/githu…
github pages: trailing directory slash in links
RomanHotsiy commentedon May 16, 2016
It redirects files as well:
Does anyone know any workaround for this?
cben commentedon May 16, 2016
Ouch.
Apparently if you have a CNAME file, github now redirects all github.io to that domain, with http :-(
I'm pretty sure this is new behavior? Don't see anything on github's blog, and wayback machine on help.github.com didn't help.
mathdown.netfile => redirects to(UPDATE: these examples no longer hold, I added/removed CNAME in these repos...)
The only current remedy seems to be removing the CNAME.
(in my case it's a leftover I forgot when I moved the custom domain to heroku/openshift; in any case, it doesn't make much sense to care about https on Pages and prefer a custom domain.)
https://help.github.com/articles/custom-domain-redirects-for-github-pages-sites/ does says it redirects, but apparently talks of a weird scenario where project page redirect involves the owner's user/org page's CNAME(?)
I've sent a lot of questions about that doc to github support, including whether the redirect could be suppressed when accessing github.io via https. Will report here if they answer.
Drop CNAME file to avoid redirect to HTTP://mathdown.net
dentarg commentedon May 17, 2016
It's not that new, I've seen it at least since beginning of October 2015. (Late October I created this related issue for Jekyll: jekyll/jekyll-redirect-from#81)
cben commentedon May 19, 2016
Got detailed reply; on https->http they said:
dentarg commentedon Jun 14, 2016
As of June 8, 2016 GitHub has finally fixed this, https://github.com/blog/2186-https-for-github-pages :-)
wchargin commentedon Sep 4, 2017
Not sure if this is a regression or it was never fully fixed, but I'm still seeing this behavior for directories:
@mastahyeti: You authored the original post (thanks for your work on this issue so far!). Is this a known bug?
z3ntu commentedon Sep 4, 2017
@wchargin Is the "Enforce HTTPS" checkbox ticked in the repository settings?
wchargin commentedon Sep 4, 2017
@z3ntu Yes. (It's been on approximately since that feature was released. I just toggled it off and on and it didn't change the result of the above command.)
cben commentedon Mar 21, 2018
This still happens, both on github.io with Enforce HTTPS on and custom domains with Enforce HTTPS on (the latter are a new thing, possibly still in rollout):
$ curl -IL https://spacem.github.io/dngearsim/builds/index.html
HTTP/2 200
$ curl -IL https://spacem.github.io/dngearsim/builds/
HTTP/2 200 (:heavy_check_mark: no redirect given trailing slash)
$ curl -IL https://spacem.github.io/dngearsim/builds
HTTP/2 301
location: http://spacem.github.io/dngearsim/builds/ ❎
HTTP/1.1 301 Moved Permanently
Location: https://spacem.github.io/dngearsim/builds/
HTTP/2 200
$ curl -IL https://github-cben-sandbox.anat-beni.net/figures/index.html
HTTP/2 404 (:heavy_check_mark: I don't have index.html there)
$ curl -IL https://github-cben-sandbox.anat-beni.net/figures/
HTTP/2 404 (:heavy_check_mark: no redirect given trailing slash)
$ curl -IL https://github-cben-sandbox.anat-beni.net/figures
HTTP/2 301
location: http://github-cben-sandbox.anat-beni.net/figures/ ❎
HTTP/1.1 301 Moved Permanently
Location: https://github-cben-sandbox.anat-beni.net/figures/
HTTP/2 404
EDIT: I see same redirects to insecure http:// whether initial request is over
--http2and--http1.1.Browsers correctly block such requests as mixed content when originated from https pages. The fix is adding the trailing slash.
Add trailing slash to urls to avoid GitHub pages redirect to http
dentarg commentedon Oct 18, 2018
I got the following from GitHub Support yesterday about this issue
EDIT:
Should probably include the complete message as this issue (#289) seems to have discussed several issues with GitHub. My reply was about the issue demonstrated by @cben above.
GitHub Support wrote:
TPS commentedon Feb 28, 2019
Does anyone have any info on further progress on this?
add trailing slash on links to ensure HTTPS
add trailing slash on links to ensure HTTPS