Simple reverse proxy to to fix GitLab Pages SSL support for GitLab usernames with dots in them.
1.0K
Simple reverse proxy to sit in front of GitLab pages, to fix SSL support for GitLab usernames with dots in them.
Currently, if a GitLab username is in the format firstname.lastname (or some other format that includes dots), GitLab will automatically set the subdomain for the user's GitLab pages to be firstname.lastname.gitlab-pages-fqdn.
As a result, we end up with an additional level of subdomain nesting that works fine for HTTP, but not at all for HTTPS. When using HTTPS, you would need to have a wildcard certificate to cover *.*.gitlab-pages-fqdn (which isn't possible), or use Let's Encrypt and somehow dynamically fetch certs and avoid their rate limiting.
Instead, this simple reverse proxy sits in front of your GitLab Pages server and rewrites URLs into something a little more browser-friendly.
Say I have a GitLab Pages server running on pages.mycorp.local, my username is fred.smith and my pages-enabled repository is called myrepo.
When I follow the GitLab-generated URL of http://fred.smith.pages.mycorp.local/myrepo, this proxy will automatically redirect the user to https://fred-smith.pages.mycorp.local/myrepo.
The request to https://fred-smith.pages.mycorp.local/myrepo is then transparently proxied to the IP address of my GitLab Pages server (not the proxy server!), and the Host header is set to http://fred.smith.pages.mycorp.local/myrepo.
From GitLab's perspective, the request comes via HTTP (not HTTPS), but all traffic between the client and proxy server is encrypted.
http://firstname.lastname.gitlab-pages-fqdn is via HTTP.This reverse proxy requires the following environment variables to be set:
If you have a wildcard SSL certificate that you'd like to use, simply mount it to /certs within the container. The proxy server will automatically use any PEM files in this folder named cert.pem and key.pem. If these files are not mounted, a self-signed wildcard certificate will be automatically generated.
docker run -d \
--name gitlab-pages-url-sanitiser \
-p 443:443 \
-p 80:80 \
-v $PWD/certs:/certs \
--env BASE_DOMAIN=pages.mycorp.local \
--env GITLAB_PAGES_SERVER_ADDRESS=http://10.1.1.1:80 \
xtrasimplicity/gitlab-pages-username-sanitisation-proxy
docker-compose.yml file:---
version: '3.5'
services:
proxy:
image: xtrasimplicity/gitlab-pages-username-sanitisation-proxy
ports:
- 80:80
- 443:443
environment:
BASE_DOMAIN: pages.mycorp.local
GITLAB_PAGES_SERVER_ADDRESS: http://10.1.1.1:80
Content type
Image
Digest
Size
62.5 MB
Last updated
over 6 years ago
docker pull xtrasimplicity/gitlab-pages-username-sanitisation-proxy