Setting your HTTP headers properly is important. Otherwise you can get an unwanted result as we'll see in this post with pages.gitlab.io.

About GitLab Pages

Gitlab is the open-source variant of Github. The GitLab Community Edition has almost all functionality that Github offers, but in contrary to Github the GitLab CE is free and open-sourced. If you want you can run GitLab CE on your own server.

Similar to Github pages, GitLab launched pages.gitlab.io a couple of months ago, mentioned in their blog post in december 2015. GitLab Pages is only available for the Enterprise Edition, but as GitLab.com runs GitLab Enterprise Edition, this service is freely available to users on Gitlab.com (which is also free to use).

HTTP header problem

When I was looking at pages.gitlab.io I got an unexpected result. I was looking for some example pages built with GitLab Pages but because I found no link to some examples, I tried to browse to pages.gitlab.io/examples. Not so surprisingly I got a HTTP 404 error, but what was unexpected whas the formatting of that error page. It looked like so:

pages.gitlab 404

It was not interpreted as a HTML page by the browser, but instead presented as a plain text file.

The problem was with the HTTP headers. Quickly using the Chrome dev tools I got the headers for http://pages.gitlab.io/examples, but for the sake of keeping my networking skills sharp I confirmed this by using telnet:

tom@turing:~$ telnet pages.gitlab.io 80
Trying 104.208.235.32...
Connected to pages.gitlab.io.
Escape character is '^]'.
HEAD /about HTTP/1.1
HTTP/1.1 404 Not Found
Content-Type: text/plain; charset=utf-8
X-Content-Type-Options: nosniff
Date: Wed, 06 Apr 2016 17:11:30 GMT
Content-Length: 19

I opened a telnet connection and issued a HTTP HEAD command to get the headers of http://pages.gitlab.io/examples. Not surprisingly the Content-Type header was set to text/plain; charset=utf-8 instead of text/html; charset=utf-8. This caused the browser to display the HTTP response as plain text instead of a HTML page.

Solution that fixes the issue

I searched the GitLab issue tracker checking whether this issue was already created. I didn't found anything so I created an issue. Two hours later they responded saying that it was fixed in this commit and will be fixed in the next 8.7RC.