GitLab Pages gives error 400 Bad Request, The plain HTTP request was sent to HTTPS port. Nginx

Good day all

I am using Sphinx to create documentation that I would like to host using GitLab Pages. Building and testing the documentation locally works as expected. I then created a CI job called “pages” which builds the Sphinx html in the pipeline and then copies it to the public artifact. I did this according to 1 and 2.

The pipeline completes successfully including the pages:deploy job and I am able to confirm that the correct files are copied to the public/ artifact. Downloading the public/ artifact and opening my index.html locally gives me the expected result.

It has been more than a day since my pipeline executed correctly but each time I open the link that pages created for my site I get the error “400 Bad Request, The plain HTTP request was sent to HTTPS port, nginx/1.17.10”. According to this it has something to do with SSL during the transaction. I have played around with these settings but with no luck.

Any help would be greatly appreciated.

I realized that the link generated for me by gitlab contains sub-subdomains. Which according to this is not supported by https.

How do I configure my pages to use the default domain

This works for me using a custom (sub)domain, and looking at one of our projects, I see that there’s also a certificate for the page on its address. I wonder whether the docs you referred to are out of date?

If you go to Settings > Pages in your repo, do you have Force HTTPS switched on, and what URLs are your pages served under?