如何在子域上的Plesk下使用Let's Encrypt with GitLab?

时间:2016-06-16 09:09:32

标签: ssl-certificate subdomain gitlab plesk lets-encrypt

我启动并运行了GitLab,但目前它还没有使用SSL。我使用Let的加密Plesk扩展来获得免费的SSL证书。 这就是我的设置:

  • Plesk v12.5.30_build1205150826.19 os_Ubuntu 14.04
  • GitLab 8.8.5
  • 让我们加密Plesk Extension v1.6第1版
  • Plesk子域名:git.my-domain.com

Plesk Apache& git.my-domain.com的nginx设置:

Additional directives for HTTP :
<Location />
    ProxyPass http://IP-of-my-domain:9999/
    ProxyPassReverse http://IP-of-my-domain:9999/
</Location>
Additional directives for HTTPS :
<Location />
     ProxyPass https://IP-of-my-domain:9998/
     ProxyPassReverse https://IP-of-my-domain:9998/
  </Location>

在我的gitlab.rb文件中:

external_url "http://IP-of-my-domain:9999/"

我还找到How do I use let’s encrypt with gitlab?并试图调整答案,但无法弄清楚要投入的内容:

nginx['custom_gitlab_server_config']="?"
nginx['custom_gitlab_mattermost_server_config']="?"

Http连接正常运行(子域或IP:端口,都可以工作)。一旦我改为Https,它就没有了,我得到以下内容(如果我将external_url更改为端口9998):

  

服务不可用

     

由于维护停机或容量问题,服务器暂时无法为您的请求提供服务。请稍后再试。

     

此外,尝试使用ErrorDocument处理请求时遇到503 Service Unavailable错误。

在ProxyPass和https之前安装了证书,没有ProxyPass条目(即证书存在且有效),没有任何问题。

如果有人通过加密运行Plesk和GitLab,我真的很感激您是否可以共享您的配置。

1 个答案:

答案 0 :(得分:1)

我在/ etc / gitlab / ssl中创建了符号链接到我的证书

  1. subdomain.domain.tld.crt =&gt; /opt/psa/var/modules/letsencrypt/etc/archive/subdomain.domain.tld/cert1.pem

  2. subdomain.domain.tld.key =&gt; /opt/psa/var/modules/letsencrypt/etc/archive/subdomain.domain.tld/privkey1.pem

  3. 在文件gitlab.rb

    external_url 'https://gitlab.domain.tld'
    gitlab_rails['gitlab_shell_ssh_port'] = 22 
    gitlab_rails['initial_shared_runners_registration_token'] = "token"
    web_server['external_users'] = ['webUser']
    nginx['enable'] = false  # Tutorial
    nginx['redirect_http_to_https'] = true      
    nginx['listen_https'] = false
    

    在Plesk:Domain =&gt; Apache&amp; nginx设置=&gt;附加的nginx指令

     location ~ / {
            # for omnibus installation
            root /opt/gitlab/embedded/service/gitlab-rails/public;
            try_files $uri $uri/index.html $uri.html @gitlab;
        }
    
        # if a file, which is not found in the root folder is requested,
        # then the proxy pass the request to the upsteam (gitlab unicorn)
        location @gitlab {
            proxy_read_timeout 300; # https://github.com/gitlabhq/gitlabhq/issues/694
            proxy_connect_timeout 300; # https://github.com/gitlabhq/gitlabhq/issues/694
            proxy_redirect     off;
    
            proxy_set_header   X-Forwarded-Proto $scheme;
            proxy_set_header   Host              $http_host;
            proxy_set_header   X-Real-IP         $remote_addr;
    
            proxy_pass http://gitlab;
    
        }
    

    在文件gitlab.conf中

      upstream gitlab {
            # for omnibus installation
            server unix:/var/opt/gitlab/gitlab-rails/sockets/gitlab.socket;
        }