美文网首页
给在 GitLab 中放置的网站启用 HTTPS

给在 GitLab 中放置的网站启用 HTTPS

作者: 冻皮 | 来源:发表于2016-12-09 16:20 被阅读0次
logo.png
  1. 前言
  2. 使用 Let’s Encrypt
  3. 使用 云盾证书服务

1. 前言

本文章需要读者知道如何在 GitLab 中搭建网站。

2. 使用 Let’s Encrypt 

2.1 使用 DNS 方法(推荐)

首先安装 certbot:

# pacman -S certbot

然后:

# certbot -d 域名 --manual --preferred-challenges dns certonly

然后会看到下面这样的东西:

Please deploy a DNS TXT record under the name
_acme-challenge.域名 with the following value:

一长串英文和数字的文本

Once this is deployed,
Press ENTER to continue

此时不要按回车键!
  去打开 DNS 解析服务,添加一个如下面的解析:

添加 TXT 解析
  过一点时间,等生效,然后就可以回到终端按回车了。
  如果顺利,会看到下面这样的东西:

IMPORTANT NOTES:
- Congratulations! Your certificate and chain have been saved at
/etc/letsencrypt/live/域名/fullchain.pem. Your cert
will expire on 2017-03-18. To obtain a new or tweaked version of
this certificate in the future, simply run certbot again. To
non-interactively renew all of your certificates, run "certbot
renew"
- If you like Certbot, please consider supporting our work by:

Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate
Donating to EFF: https://eff.org/donate-le

此时证书已经生成完成了。
  接下来就是应用证书了,在 GitLab 上的项目 的 Add Domain 页面,分别填上 域名和/etc/letsencrypt/live/域名/fullchain.pem/etc/letsencrypt/live/域名/privkey.pem 里面的内容,再点击 "Create New Domain" 就行了。

2.2 使用文件方法

首先安装 certbot:

# pacman -S certbot

然后:

# certbot certonly -a manual -d 域名

然后看到有类似这样的东西:

Make sure your web server displays the following content at
http://域名/.well-known/acme-challenge/一长串东西 before continuing:

nUwHqxgYTBM33SbD8Rbq6I4kRAM__ihN1AamLiliSRU.00rwBJnorqAUOqwnjUha-sybA9YQgo2YTMIr_q2A3j0

If you don't have HTTP server configured, you can run the following
command on the target server (as root):

mkdir -p /tmp/certbot/public_html/.well-known/acme-challenge
cd /tmp/certbot/public_html
printf "%s" 这里有一长串东西 > .well-known/acme-challenge/这里也有一长串东西

# run only once per server:

$(command -v python2 || command -v python2.7 || command -v python2.6) -c \
"import BaseHTTPServer, SimpleHTTPServer; \
s = BaseHTTPServer.HTTPServer(('', 80), SimpleHTTPServer.SimpleHTTPRequestHandler); \
s.serve_forever()" 

Press ENTER to continue

看到上面这些东西不要立刻按回车键,因为还没把用来验证的东西上传到 GitLab。
  首先创建个两个文件夹在:

mkdir -p ~/放着网页的目录/.well-known/acme-challenge
cd ~/放着网页的目录
printf "%s" 这里有一长串东西 > .well-known/acme-challenge/这里也有一长串东西

然后把刚加入的东西推到 GitLab 上,过段时间之后去之前出现的http://域名/.well-known/acme-challenge/一长串东西页面。此时看到页面上应该是一长串字符,如果不是,那就看下是不是部署出错了。
  到现在可以回到终端,按下回车键了。
  如果顺利,会看到下面这样的东西:

IMPORTANT NOTES:
- Congratulations! Your certificate and chain have been saved at
/etc/letsencrypt/live/域名/fullchain.pem. Your cert will
expire on 2017-03-09. To obtain a new or tweaked version of this

certificate in the future, simply run certbot again. To
non-interactively renew all of your certificates, run "certbot
renew"
- If you like Certbot, please consider supporting our work by:

Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate
Donating to EFF: https://eff.org/donate-le

此时证书已经生成完成了。
  接下来就是应用证书了,在 GitLab 上的项目 的 Add Domain 页面,分别填上 域名和/etc/letsencrypt/live/域名/fullchain.pem/etc/letsencrypt/live/域名/privkey.pem 里面的内容,再点击 "Create New Domain" 就行了。

3. 使用 云盾证书服务 

进入 云盾证书服务 的购买页面,选择需要的版本(本人穷,未对收费版进行测试)进行购买。
  然后进入 证书服务控制台 ,选择补全,填上域名,信息。如果是用阿里的解析,推荐用 DNS 并勾选,完成后就等签发了。选择其他的也可以,这里就不说了。


参考来源

Tutorial: Securing your GitLab Pages with TLS and Let's Encrypt | GitLab 
How to use Let's Encrypt DNS challenge validation? - Server Fault 


本文其他链接:《在 GitLab 中放置网页并启用 HTTPS》——冻皮博客 (未完成)


知识共享许可协议
本作品采用 知识共享署名-相同方式共享 4.0 国际许可协议  进行许可。

你是否看到本文不少链接后面有个方框?不要方,这是因为你没安装 Font Awesome  字体,安装后这个问题就会消失啦~

相关文章

  • 给在 GitLab 中放置的网站启用 HTTPS

    前言 使用 Let’s Encrypt 使用 云盾证书服务 1. 前言 本文章需要读者知道如何在 GitLab 中...

  • Gitlab部署

    一、查看GitLab的官方网站 GitLab的官方网站找到对应系统安装gitlab的介绍页面如下:https://...

  • git学习------> CenterOS上安装GitLab并自

    第一步 查看GitLab的官方网站 GitLab的官方网站关于安装gitlab的介绍页面如下:https://ab...

  • HSTS详解

    文/马伟 缘起:启用HTTPS也不够安全 有不少网站只通过HTTPS对外提供服务,但用户在访问某个网站的时候,在浏...

  • HSTS详解

    1. 缘起:启用HTTPS也不够安全 有不少网站只通过HTTPS对外提供服务,但用户在访问某个网站的时候,在浏览器...

  • Laravel 强制使用 https

    背景 前段时间给自己的网站安装了 SSL 证书,启用了 https。然而 laravel 本身并没有任何改变,资源...

  • gitlab介绍

    gitlab介绍 Gitlab的优势和应用场景 开源免费,适合中小型公司将代码放置在该系统中 差异化的版本管理,离...

  • 2022-12-14 虚拟机Ubuntu+Docker+Gitl

    Ubuntu中安装Docker GitLab Docker images | GitLab[https://doc...

  • centos7-docker运行gitlab

    centos7-docker运行gitlab 1. 准备配置文件gitlab.rb放置于/gitlab/confi...

  • 启用 HTTPS

    背景 最近为了扛 DDoS 攻击,从移动公司申请了一台服务器,移动公司免费提供流量清洗功能。但由于没有备案,移动公...

网友评论

      本文标题:给在 GitLab 中放置的网站启用 HTTPS

      本文链接:https://www.haomeiwen.com/subject/dksrmttx.html