Please note that this question relates to personal use of a dedicated server, not professional.
I want to run two GitLab Docker Containers on the same machine with two different volumes, the two of them "made available" on port 443 on the hosts' machine. Port 80 for http content is not made available. The host's HTTP will not be a 3xx redirect, it will be a web page using HSTS. SSH ports on the hosts' will be something like 10703 and 10803.
The urls will be https://gitlab.example.com and https://sources.example.com. The certificates are maintained by Let's Encrypt on the host.
The content will be served by Apache, using mod_proxy and virtual hosts. Apache does not run inside Docker. There are other virtual hosts enabled unrelated to GitLab. In order to simplify certificates, I'm trying not to put certificates inside the gitlab themselves. Instead the Apache configuration holds the certificates.
- https://gitlab.example.com will forward to http://127.0.0.1:10701 or whatever port is used to serve the web content depending on the current GitLab configuration
- https://sources.example.com will forward to http://127.0.0.1:10801
Now here come the issues.
If I specify https://gitlab.example.com as the external_url:
- https will be enabled. gitlab will refuse to even start because the certificates are missing. As I said I'm using mod_proxy, I don't need certificates because Apache is doing all the work already. I would like GitLab to serve insecure content locally to Apache so that it's Apache's job to make that secure over untrusted network.
If I specify http://gitlab.example.com as the external_url and let Apache forward to http://127.0.0.1:10701, which is port 80 on the Docker Container:
- almost all gitlab web resources will be served through http://gitlab.example.com, causing the browser to indicate the site is in practice insecure, which is understandable.
- the copy and paste link to clone a gitlab repository will be
http://gitlab.example.com/group/something.git
, causing the clone links to fail because it's not https.
SSH is forwarded from the port 10703 on the host's machine. Inside the Docker Container, it's running on port 22. The current SSH cloning copy and paste link is still
git@gitlab.example.com:group/something.git
. I want it to bessh://git@gitlab.example.com:10703/group/something.git
(see answer about cloning on other ports)
My X
problem is:
To serve GitLab web interfaces securely on the standard https port of the host (443).
To preserve the usability of the copy and paste links of the web interface content, with no compromise on security.
Constraint: Apache must not be replaced.
My current Y
ideal solution is:
- I would like to strongly decouple GitLab's configuration from intent. Currently when I configure the external URL to https, it recognizes the intent to be serving secure content, which requires certificates. When in fact, I just want the external URL to change. Same deal with SSH, separate external displayed port (used for copy and paste links) from actual networking port from the container's perspective. Maybe there is a configuration that allows this.
My current Y
quick and dirty solutions are:
Use https://... as the external url, and add placeholder certificate files to
/etc/gitlab/ssl/
. GitLab will ignore these certificates completely, but as long as they are present in the filesystem, GitLab will be able to start and the host will be able to deliver secure content. I would like to avoid doing this if there is a better alternative.To solve the SSH problem, Maybe I could add
gitlab_rails['gitlab_shell_ssh_port'] = 10703
(see answer about changing SSH port)and then use(docker run --publish 10703:10703 ...
instead of how it's currently donedocker run --publish 10703:22 ...
). EDIT: It turns out thatgitlab_rails['gitlab_shell_ssh_port']
only changes the displayed port. Since it's sshd that manages the port 22 and not gitlab,docker run --publish 10703:10703 ...
will cause port 10703 on the host to be forwarded to port 10703 on the container, which is closed.docker run --publish 10703:22 ...
+gitlab_rails['gitlab_shell_ssh_port'] = 10703
is how it should be done.
How can I solve this problem? Both elegant and quick and dirty ways are appreciated.