Gitlab links to “https://gitlab/”

落花浮王杯 提交于 2021-01-27 17:35:41

问题


I installed gitlab in a docker container from the official image gitlab/gitlab-ce:latest. This image has all config in the file gitlab.rb. Https is done by a nginx reverse proxy.

My problem is, that when gitlab has an absolute link to itself, it links always to https://gitlab/. This host also can be seen in the "New group" dialog:

Docker call:

docker run \
       --name git \
       --net mydockernet \
       --ip 172.18.0.2 \
       --hostname git.mydomain.com \
       --restart=always \
       -p 766:22 \
       -v /docker/gitlab/config:/etc/gitlab \
       -v /docker/gitlab/logs:/var/log/gitlab \
       -v /docker/gitlab/data:/var/opt/gitlab \
       -d \
       gitlab/gitlab-ce:latest

gitlab.rb:

external_url 'https://git.mydomain.com'
ci_nginx['enable'] = false
nginx['listen_port'] = 80
nginx['listen_https'] = false

gitlab_rails['gitlab_shell_ssh_port'] = 766

Nginx config:

upstream gitlab {
    server 172.18.0.2;
}
server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name git.mydomain.com;

        ssl on;
        ssl_certificate /etc/ssl/certs/mydomain.com.chained.pem;
        ssl_certificate_key /etc/ssl/private/my.key;

    location / {
        proxy_pass http://gitlab/;
                proxy_read_timeout 10;
    }
}

I tried to replace the wrong url wit nginx. This worked for the appearance like in the screen shot, but not for the links:

sub_filter 'https://gitlab/' 'https://$host/';
sub_filter_once off;

回答1:


You've set your url correctly in your mapped volume /etc/gitlab/gitlab.rb

external_url 'https://git.mydomain.com'

Run sudo gitlab-ctl reconfigure for the change to take effect.




回答2:


Problem solved. It was in the nginx reverse proxy config. I named the upstream "gitlab" and somehow this name found it's way into the web pages:

upstream gitlab {
    server 172.18.0.2;
}
...
proxy_pass http://gitlab/;

I didn't expect that. I even omitted the upstream part in my original question because I thought the upstream name is just an internal name and will be replaced by the defined ip.

So the fix for me is, to write the full domain into the upstream:

upstream git.mydomain.com{
    server 172.18.0.2;
}
...
proxy_pass http://git.mydomain.com/;


来源:https://stackoverflow.com/questions/38583505/gitlab-links-to-https-gitlab

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!