如何使用 gitlab 进行加密?

2024-01-15

当我偶然发现时,我开始研究 ssl 证书让我们加密 https://letsencrypt.org,我想将它与 gitlab 一起使用,但是它正在树莓派 2 上运行并且现在运行得非常完美(所以我不想搞乱任何事情),他会我去正确安装一个让加密的 ssl 证书? PS:我的安装是综合的


迄今为止我能找到的最佳解决方案描述于这篇博文 https://webnugget.de/setting-up-gitlab-with-free-ssl-certs-from-lets-encrypt-on-ubuntu-14-04/。我不会全部背诵,但要点是:

  • Use the webrootLet's Encrypt 的验证器
  • 创建文件夹/var/www/letsencrypt并使用该目录作为webroot-path让我们加密
  • 更改以下配置值/etc/gitlab/gitlab.rb并运行gitlab-ctl reconfigure在那之后:

    nginx['redirect_http_to_https'] = true
    nginx['ssl_certificate']= "/etc/letsencrypt/live/gitlab.yourdomain.com/fullchain.pem"
    nginx['ssl_certificate_key'] = "/etc/letsencrypt/live/gitlab.yourdomain.com/privkey.pem"
    nginx['custom_gitlab_server_config']="location ^~ /.well-known {\n alias /var/www/letsencrypt/.well-known;\n}\n"
    
  • 如果您使用的是 Omnibus 包附带的 Mattermost,那么您还可以在/etc/gitlab/gitlab.rb:

    mattermost_nginx['redirect_http_to_https'] = true
    mattermost_nginx['ssl_certificate']= "/etc/letsencrypt/live/gitlab.yourdomain.com/fullchain.pem"
    mattermost_nginx['ssl_certificate_key'] = "/etc/letsencrypt/live/gitlab.yourdomain.com/privkey.pem"
    mattermost_nginx['custom_gitlab_mattermost_server_config']="location ^~ /.well-known {\n alias /var/www/letsencrypt/.well-known;\n}\n"
    
  • 申请第一个证书后,请记住更改external_url to https://...并再次运行gitlab-ctl reconfigure

这个方法非常优雅,因为它只是挂载目录/var/www/letsencrypt/.well-knownLet's Encrypt 身份验证器通过自定义 Nginx 配置使用到 Gitlab Web 根目录,并且在 Gitlab 运行时始终可以进行身份​​验证。这意味着您可以自动续订 Let's Encrypt 证书。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何使用 gitlab 进行加密? 的相关文章

随机推荐