This portfolio took some time to get setup and running, not because of its content or due to the use of Hugo. That was the easy bit. The hard bits and pieces came after having some content prepared.

Self Hosting Link to heading

As evident in my about page, I enjoy self hosting things that I regularly use when possible. This portfolio is one of those things. I had decided to make use of Gitlab’s CI/CD to take care of the deployment for my portfolio, ofcourse that Gitlab is already hosted by me with the use of Traefik it is available over the internet too.

Gitlab Pages Link to heading

First step to getting this portfolio up and running was enabling and configuring Gitlab Pages. By default this is not the case and requires a few configuration changes in the gitlab.rb file.

pages_external_url "http://pages.awaly.nl/"  # Needs to be a different domain than the domain gitlab is hosted on.
gitlab_pages['enable'] = true 

These two settings tell Gitlab to enable pages and defines an external url all of the websites created with pages will be using. This is the bare minimum to get pages configured with Gitlab and running, that is if you don’t use a reverse proxy.

In the event you do use a reverse proxy like myself, additional settings are needed.

pages_nginx['enable'] = true
pages_nginx['listen_port'] = 80 # Port configured for traffic
pages_nginx['listen_https'] = false # With the use of an SSL terminating proxy like traefik, nginx doesn't need to bother with https.
pages_nginx['redirect_http_to_https'] = true

It became clear that Gitlab Pages works by having a separate nginx instance running that handles all of the pages, pretty neat. This also means that it needs to be configured properly. The settings above do so in my situation where Gitlab is running within a container and behind a reverse proxy using Traefik. Ofcourse this is only the settings needed for Gitlab. Traefik needs to be made aware of this new feature and router appropriately for it and ofcourse renew its SSL certificate.

Traefik Link to heading

With Traefik there are multiple methods of configuring routes, I have chosen for the dynamic method which uses labels attached to containers to tell Traefik how to handle this container.

traefik.enable=true
traefik.network=traefik_network
traefik.http.routers.gitlab.rule=Host(`gitlab.awaly.nl`) || Host(`pages.awaly.nl`) || Host(`awaly.pages.awaly.nl`)
traefik.http.routers.gitlab.tls.certresolver=lets-encrypt
traefik.http.routers.gitlab.tls=true
traefik.http.routers.gitlab.service=gitlab
traefik.http.services.gitlab.loadbalancer.server.port=80
io.containers.autoupdate=registry # optional, this is used for auto-updating podman containers.

Make note of the follow rule traefik.http.routers.gitlab.rule. This tells Traefik what host’s it should forward to this container. I have added the gitlab domainn, the pages domain and the pages domain pre-pending my username. The last one is needed because Gitlab Pages is set up in a way that each user or group gets its own subdomain for all of the pages a user or group may ever want to use.

An example of how a url like this looks like would be http://awaly.pages.awaly.nl/portfolio. The last section portfolio is the name of the project itself, in this case it is the project which contains this portfolio.

DNS Link to heading

Now with a page setup and running. The only issue that remains is that it is a rather ugly URL, not to mention long. Good thing DNS is a thing that can resolve this.

I can make a subdomain like http://portfolio.awaly.nl and setup a permanent redirect to the actual URL.