Project URL refers to `localhost`?

Hi Gitlab Community!

I am running a docker image of gitlab-ce behind an nginx running on the host OS (Debian 10). The installation is working fine but there is one thing I can’t get my head around:

When creating a new group or project, the URL field says http://localhost:10080/gitlab/. While this is technically correct, I thought it should rather show the external URL (http://foo/dnshome/de/gitlab/). Once a project is created, the clone link contains the external URL, as expected, and I can clone repos using these URLs.

I thought I had understood the documentation (https://docs.gitlab.com/omnibus/docker/) and used the external_url setting as well as --hostname in my run.sh script but apparently, I there is still something I didn’t quite grasp.

Any hints or pointers to the appropriate part of the docs are appreciated.

This is my run.sh:

#!/usr/bin/bash                                                                                                                                   
export GITLAB_HOME=/srv                                                                                                                           

docker run --detach \                                                                                                                             
    --hostname foo.dnshome.de \                                                                                                                 
    --env GITLAB_OMNIBUS_CONFIG="external_url 'http://foo.dnshome.de/gitlab/'" \                                                                
    --publish 10080:80 \                                                                                                                          
    --publish 10443:443 \                                                                                                                         
    --name gitlab \                                                                                                                               
    --restart always \                                                                                                                            
    --volume $GITLAB_HOME/gitlab/config:/etc/gitlab \                                                                                             
    --volume $GITLAB_HOME/gitlab/logs:/var/log/gitlab \                                                                                           
    --volume $GITLAB_HOME/gitlab/data:/var/opt/gitlab \                                                                                           
    gitlab/gitlab-ce:latest

My home server is behind a fritzbox router that uses a dynamic DNS service.

My nginx config (sites-available) contains this for redirection:

       location /gitlab/ {
                proxy_pass http://localhost:10080;
                #proxy_pass https://localhost:10443;
        }

Thanks in advance
Phil

You can set http header by nginx config :

location /gitlab/ {
                proxy_pass http://localhost:10080;
                proxy_set_header Host $host;
        }

The nginx configuration you provided is missing the proxy_set_header X-Forwarded-Proto directive, which could be causing the issue with the project URL showing localhost instead of the external URL.
You can update your nginx configuration as follows so that GitLab recognizes the correct external URL

location /gitlab/ {
  proxy_pass http://localhost:10080;
  proxy_set_header Host $host;
  proxy_set_header X-Forwarded-Proto $scheme;
}

restart nginx and check.

tips for this type for error you can use RedirectChecker.com to get its detail redirection chain and its http status code, latency and more information.