Skip to content

Nginx反向代理

当前gitlab登录路径是localhost:8080

$ curl localhost:8800
<html><body>You are being <a href="http://localhost:8800/users/sign_in">redirected</a>.</body></html>

地址会跳转到http://localhost:8800/users/sign_i,下面通过反向代理简化登录地址

调整gitlab登录地址

修改gitlab配置文件/etc/gitlab/gitlab.rb,修改external_url访问路径

external_url 'http://localhost:8800/gitlabs/'

更新gitlab配置

$ gitlab-ctl reconfigure
$ gitlab-ctl restart

nginx配置

修改nginx配置文件/etc/nginx/conf.d/default.conf,新增location

$ cat gitlab.conf 
server {
    ...
    ...
    location /gitlabs/ {
        proxy_pass http://localhost:8800;
    }
    ...
    ...
}

刷新nginx

$ sudo nginx -t
$ sudo nginx -s reload

之后输入localhost/gitlabs/即可登录gitlab