Using Gitlab docker behind nginx proxy manager docker

I try to setup Nginx Proxy Monitor(NGPM) as a reverse proxy for Gitlab and other websites/services. Gitlab itself is running inside a docker container that has it’s own IP address. NGPM is also inside a docker container. Both containers run on an Unraid server (and were installed from the “Apps” which, in this case are prefilled docker templates)

I’ve tried this:
https://www.itsfullofstars.de/2019/06/gitlab-behind-a-reverse-proxy/

But this just lead to a 502 Bad Gateway error from Nginx.

Also tried some other things, but most links I find talk about decoupling the nginx from gitlab with an nginx on the same machine pointing to some gitlab stuff.

At this point I am lost to why nothing works, and am just poking around in config files without really knowing what I am doing. I don’t even know what to provide you with in order to help me, so please, if you need sth. to help me with my problem I’ll gladly attach that.

Edit Logs:
Error log looks like this:

2020/06/24 11:55:54 [error] 2834#2834: *1966 connect() failed (113: Host is unreachable) while connecting to upstream, client: 0.0.0.0, server: develop.company.com, request: "GET / HTTP/2.0", upstream: "http://192.168.10.170:80/", host: "develop.company.com", referrer: "http://192.168.10.135:7818/nginx/proxy" 

Access Log like this:

[24/Jun/2020:11:49:56 +0200] - 502 502 - GET https develop.company.com "/" [Client 0.0.0.0] [Length 166] [Gzip -] [Sent-to 192.168.10.170] "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:77.0) Gecko/20100101 Firefox/77.0" "http://192.168.10.135:7818/nginx/proxy"   
[24/Jun/2020:11:49:56 +0200] - - 499 - GET https develop.company.com "/favicon.ico" [Client 0.0.0.0] [Length 0] [Gzip -] [Sent-to 192.168.10.170] "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:77.0) Gecko/20100101 Firefox/77.0" "-"

Note that I changed the client IP for the purpose of uploading here. Since I’m testing it from within the network where proxy and gitlab are located, this is our external IP.

Edit Config:
Gitlab:
I tried only with this:
external_url="https://develop.company.com
But also this:
nginx['listen_port'] = 80
nginx['listen_https'] = false

I also tried the http variant for external_url.

NGPM:
enter image description here
enter image description here
I also tried http with 443, https with 80, but it didn’t matter (and also wouldn’t have made much sense).

Answer

Bridging the network connection for the docker container in Unraid, instead of giving it it’s own IP address, did the trick, the reverse proxy seems to work fine now.

Here all the “Setup” that I needed.
In the gitlab.rb file you need to uncomment/set these values:

external_url="https://develop.company.com
nginx['listen_port'] = 80
nginx['listen_https'] = false

Note, that the https:// is necessary here.

The entry in the NGPM:
enter image description here

The Unraid container config:
enter image description here

So yeah. Don’t know why this didn’t work when Gitlab had it’s own IP address, but this works as expected now.

Attribution
Source : Link , Question Author : EaranMaleasi , Answer Author : EaranMaleasi

Leave a Comment