Gitlab URL does not show real URL

Hello,

I am running Gitlab in a docker container. At few places, gitlab does not display the URL defined in the config file as external_url but shows the local URL of the container (localhost:port).
This poses problems for people running gitlab in containers or behind proxies.

The problem seems to come from root_url 's definition.
Steps to reproduce :

  1. Run the latest gitlab-ee image in docker
  2. Log in
  3. Create a new project. Notice that project URL is not pointing to external_url

Could you please advise me if this is a configuration problem.

Hi @dhiachou, welcome to the GitLab Community Forum!

I think this might be a

Can you verify if whether or not you:

  1. used the instructions here to install the GitLab docker container
  2. set the correct URL in external_url in your /etc/gitlab/gitlab.rb file that
  3. the --hostname <URL> specified when launching the container matches the external_url in your /etc/gitlab/gitlab.rb?
  4. that gitlab-ctl reconfigure ran following the update to your gitlab.rb

Can you also please share where you’re setting or seeing the root_url definition you mentioned?

Thanks in advance.

Hello @gitlab-greg, thank you for your reply !
I verified that all the configs mentioned in the instructions match mine.

I am using docker-compose for the config here is its content :

web:
  image: 'gitlab/gitlab-ee:latest'
  restart: always
  hostname: 'gitlab.mydomain'
  environment:
    GITLAB_OMNIBUS_CONFIG: |
      external_url 'http://gitlab..mydomain'
      unicorn['worker_processes'] = 3
      sidekiq['concurrency'] = 4
      gitlab_rails['gitlab_shell_ssh_port'] = 2224
      postgresql['shared_buffers'] = "4GB"
  ports:
    - '8929:80'
    - '2224:22'
  volumes:
    - '/srv/gitlab/config:/etc/gitlab'
    - '/srv/gitlab/logs:/var/log/gitlab'
    - '/srv/gitlab/data:/var/opt/gitlab'

I did perform the gitlab-ctl reconfigure manually to no avail. Although it is expected as I did not modify gitlab.rb.

The project URL is still pointing to localhost:8929 instead of gitlab.mydomain

the root_url I mentionned is what is used in the view

app/views/import/shared/_new_project_form.html.haml

. Although I am not sure as to where it is defined.

Thanks in advance.

I found a workaround.
Adding the following parameters to the containerized nginx fixes the issue.

nginx['proxy_set_headers'] = {
    'Host' => 'gitlab.myproxy.mydomain',
    'X-Forwarded-Proto' => 'https',
    'X-Forwarded-Ssl' => 'on'
  }