How do I configure the hostname for the GitLab NixOS service?

Solution 1:

The desired behavior can achieved with the proxy_set_header NGINX directive:

proxy_set_header Host       $host;

If you include this line in the reverse proxy configuration, NGINX will rewrite the host header (i.e. localhost) sent back from the upstream server (i.e. GitLab) with the hostname from the original request (i.e. example.org). Enabling the services.nginx.recommendedProxySettings option in NixOS will generate NGINX configuration with the directive included.