skip to Main Content

I’m using gitlab on a relative url domain.com/gitlab behind a reverse proxy, however I’m having some troubles with a few features.

I had to set external_url=http://<ip-address>:<port> to be able to access gitlab with my reverse proxy. When I create a project gitlab shows the correct project url in the creation process https://my.domain.com/gitlab/<username|groupname>/<newprojectname> as well as in the settings of existing projects. However the clone button still shows http://<ip-address>:<port>/gitlab/<username|groupname>/<newprojectname> which of course isn’t working. I’ve added the slack webhook integration to receive updates on merge requests, pushs, etc. and it’s the same problem there. The slack messages have links which look something like this http://<ip-address>:<port>/gitlab/<username|groupname>/<someidentifier>.

Could this be a problem with the gitlab version or am I missing some settings?

Gitlab gitlab/gitlab-ce:14.9.4-ce.0

gitlab_rails['gitlab_shell_ssh_port'] = 2224
external_url 'http://<server-ip-address>:<docker-port>/gitlab/'
gitlab_rails['trusted_proxies'] = ['<server-ip-address>']
nginx['proxy_set_headers'] = {
  "X-Forwarded-Proto" => "https",
  "X-Forwarded-Ssl" => "on",
  "Host" => "my.domain.com",
  "X-Real-IP" => "$$remote_addr",
  "X-Forwarded-For" => "$$proxy_add_x_forwarded_for",
}

Nginx: nginx:1.21.6-alpine

##############
##  GITLAB  ##
##############
  location /gitlab/ {
    root /home/git/gitlab/public;

    client_max_body_size 0;

    proxy_http_version 1.1;
    proxy_pass http://<server-ip-address>:<docker-port>/gitlab/;

    gzip                    off;

    proxy_read_timeout      300;
    proxy_connect_timeout   300;
    proxy_redirect          off;


    proxy_set_header    Host                $host;
    proxy_set_header    X-Real-IP           $remote_addr;
    proxy_set_header    X-Forwarded-For     $proxy_add_x_forwarded_for;
    proxy_set_header    X-Forwarded-Proto   https;
    proxy_set_header    X-Forwarded-Ssl     on;
  }

2

Answers


  1. Chosen as BEST ANSWER

    For anyone else trying this, the following worked for me:

    gitlab_rails['gitlab_shell_ssh_port'] = 2224
    external_url 'https://my.domain.com/gitlab/'
    nginx['listen_port'] = 8929
    nginx['listen_https'] = false
    nginx['proxy_set_headers'] = {
      "X-Forwarded-Proto" => "https",
      "X-Forwarded-Ssl" => "on",
      "Host" => "$$host",
      "X-Real-IP" => "$$remote_addr",
      "X-Forwarded-For" => "$$proxy_add_x_forwarded_for",
    }
    
     location /gitlab/ {
        root /home/git/gitlab/public;
    
        client_max_body_size 0;
    
        proxy_http_version 1.1;
        proxy_pass http://<server-ip-address>:8929/gitlab/;
    
        gzip                    off;
    
        proxy_read_timeout      300;
        proxy_connect_timeout   300;
        proxy_redirect          off;
    
    
        proxy_set_header    Host                $host;
        proxy_set_header    X-Real-IP           $remote_addr;
        proxy_set_header    X-Forwarded-For     $proxy_add_x_forwarded_for;
        proxy_set_header    X-Forwarded-Proto   https;
        proxy_set_header    X-Forwarded-Ssl     on;
      }
    

  2. See the documentation for Installing GitLab under a Relative URL. It involves changing configuration in a few different files.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search