<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                # 17. 給 GitLab 應用加上 https #### 1. 介紹 在以前的一篇文章我們介紹過如何用docker來部署gitlab應用:[使用 compose 部署 GitLab 應用 (八)](https://www.rails365.net/articles/shi-yong-compose-bu-shu-gitlab-ying-yong-ba) 還有一篇文章是介紹用`acme.sh`給網站加上https的:[使用 acme.sh 安裝 Let’ s Encrypt 提供的免費 SSL 證書](https://www.rails365.net/articles/shi-yong-acme-sh-an-zhuang-let-s-encrypt-ti-gong-mian-fei-ssl-zheng-shu) 現在這篇文章來結合之前的兩篇文章的內容,給gitlab網站加上https應用的。 #### 2. 申請證書 第一步是申請證書: ``` $ acme.sh --issue -d gitlab.rails365.net -w /srv/docker/gitlab/gitlab ``` `/srv/docker/gitlab/gitlab`是gitlab這個docker所使用的數據卷的目錄。 執行這行命令,你會發現輸出是這樣的: ``` [Sun Mar 12 11:06:15 CST 2017] Single domain='gitlab.rails365.net' [Sun Mar 12 11:06:15 CST 2017] Getting domain auth token for each domain [Sun Mar 12 11:06:15 CST 2017] Getting webroot for domain='gitlab.rails365.net' [Sun Mar 12 11:06:15 CST 2017] Getting new-authz for domain='gitlab.rails365.net' [Sun Mar 12 11:06:20 CST 2017] The new-authz request is ok. [Sun Mar 12 11:06:20 CST 2017] Verifying:gitlab.rails365.net [Sun Mar 12 11:06:25 CST 2017] gitlab.rails365.net:Verify error:Invalid response from http://gitlab.rails365.net/.well-known/acme-challenge/M383V-Nx8XeuYkzt5gUYIufSbiOuMB5ox3OZyKXz21M: [Sun Mar 12 11:06:25 CST 2017] Please add '--debug' or '--log' to check more details. [Sun Mar 12 11:06:25 CST 2017] See: https://github.com/Neilpang/acme.sh/wiki/How-to-debug-acme.sh ``` 主要報錯的這一行是這里: ``` gitlab.rails365.net:Verify error:Invalid response from http://gitlab.rails365.net/.well-known/acme-challenge/M383V-Nx8XeuYkzt5gUYIufSbiOuMB5ox3OZyKXz21M ``` 其實`acme.sh`要驗證一下這個網站的所有權,也就是說只要你能證明這個網站或域名你是能控制的,就可以了,它是通過向網站寫些數據,或讀些數據來驗證的,比如,在你的網站根目錄下新建一個目錄`.well-known`,再往里面寫些東西。 所以我們只要用nginx把這個處理一下就好了: 比如: ``` location /.well-known/ { root /srv/docker/gitlab/gitlab; } ``` > 下面會給出完整的配置的。 然后再執行之前的命令就會成功的。 接著把證書安裝到gitlab那里。 ``` $ mkdir /srv/docker/gitlab/gitlab/ssl $ acme.sh --installcert -d gitlab.rails365.net \ --keypath /srv/docker/gitlab/gitlab/ssl/gitlab.rails365.net.key \ --fullchainpath /srv/docker/gitlab/gitlab/ssl/gitlab.rails365.net.key.pem \ --reloadcmd "sudo nginx -s reload" $ openssl dhparam -out /srv/docker/gitlab/gitlab/ssl/dhparam.pem 2048 ``` 最后nginx里加上配置: ``` upstream gitlab { server 127.0.0.1:10080; } server { listen 443 ssl; server_name gitlab.rails365.net; ssl_certificate /srv/docker/gitlab/gitlab/ssl/gitlab.rails365.net.key.pem; ssl_certificate_key /srv/docker/gitlab/gitlab/ssl/gitlab.rails365.net.key; # ssl_dhparam ssl_dhparam /srv/docker/gitlab/gitlab/ssl/dhparam.pem; server_tokens off; root /dev/null; # 配合acme.sh使用ssl, 驗證網站 location /.well-known/ { root /srv/docker/gitlab/gitlab; } location / { proxy_read_timeout 300; proxy_connect_timeout 300; 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_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Frame-Options SAMEORIGIN; proxy_pass http://gitlab; } } server { listen 80; server_name gitlab.rails365.net; return 301 https://gitlab.rails365.net$request_uri; } ``` #### 3. 改造gitlab 經過前面的處理,也是能正常訪問的,不過好像有些問題,因為gitlab網站里面還是在使用http協議作為代碼的訪問協議,而不是https。 這里要把gitlab改造一下。 打開`docker-compose.yml`文件,主要更改以下幾個地方: ``` - GITLAB_HTTPS=true - GITLAB_PORT=443 gitlab: restart: always image: sameersbn/gitlab:8.15.2 depends_on: - redis - postgresql ports: - "10080:80" - "10022:22" - "10443:443" ... - GITLAB_HTTPS=true - SSL_SELF_SIGNED=false - GITLAB_HOST=gitlab.rails365.net - GITLAB_PORT=443 - GITLAB_SSH_PORT=10022 ``` 開啟了gitlab的https服務,把https的服務的端口改為了443,并且暴露了`10443`端口。 然后nginx里也改變一下: ``` upstream gitlab { server 127.0.0.1:10443; } location / { ... proxy_pass https://gitlab; } ``` 端口變了,變成了`10443`,還有`http://gitlab`變成了`https://gitlab`。 #### 4. 復制證書 你要把證書復制到gitlab下。 ``` mkdir -p /srv/docker/gitlab/gitlab/certs cp /srv/docker/gitlab/gitlab/ssl/gitlab.rails365.net.key.pem /srv/docker/gitlab/gitlab/certs/gitlab.crt cp /srv/docker/gitlab/gitlab/ssl/gitlab.rails365.net.key /srv/docker/gitlab/gitlab/certs/gitlab.key cp /srv/docker/gitlab/gitlab/ssl/dhparam.pem /srv/docker/gitlab/gitlab/certs/dhparam.pem chmod 400 /srv/docker/gitlab/gitlab/certs/gitlab.key ``` 現在可以正常以https訪問gitlab了。 ![](https://box.kancloud.cn/0be73644cf6c628fb32ed29fc6b25e76_992x318.png) ![](https://box.kancloud.cn/db9980749c3fe19c0c871db43aa76092_2616x702.png) 完結。
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看