未分类

Certbot issues free certificates

SSL 免费证书申请 – Certbot

什么是 Certbot?

Certbot 是一个开源的自动化工具,用于获取和续订由 Let’s Encrypt 提供的免费 SSL/TLS 证书。

Let’s Encrypt 是一个由互联网安全研究小组(ISRG)运营的证书颁发机构(CA),它提供了一个自动化的流程来生成和更新证书,使得网站管理员可以轻松地为他们的站点启用 HTTPS 加密。

Certbot 的主要特点包括:

  • 自动化:它可以自动验证域名所有权,并申请证书。
  • 免费:它使用的是 Let’s Encrypt 提供的免费证书。
  • 兼容性:支持多种 web 服务器,如 Apache、Nginx 等。
  • 易用性:提供了命令行界面,使得安装和使用变得简单。
  • 续订:自动处理证书的续订,确保网站的 HTTPS 连接始终保持有效。

Let’s Encrypt 颁发的证书有效期为 90 天,Certbot 会自动配置证书的续期任务,确保证书不会过期。

1)docker部署Cerbot

# 下载镜像
docker pull registry.cn-shenzhen.aliyuncs.com/xielincai/devops:certbot

备注:

这个镜像是自己封装好的certbot工具,里面包含了dns-aliyun,dns-cloudflare2个dns插件,可签发阿里云和cloudflare平台的域名

2)创建certbot容器

docker run -it -d --name  --network host certbot registry.cn-shenzhen.aliyuncs.com/xielincai/devops:certbot

3)签发阿里云证书

certbot certonly  --preferred-challenges dns -d "*.obsbot.com.cn" -d obsbot.com.cn --manual-auth-hook "alidns" --manual-cleanup-hook "alidns clean"

备注:

执行以上命令后,还需填写信息,详细内容可查看,SSL 免费证书申请 – Certbot | 菜鸟教程

Docker builds Jenkins

1)下去最新jenkins镜像

docker pull registry.cn-shenzhen.aliyuncs.com/xielincai/devops:jenkins_lts

或者去这个地址下载镜像:docker.io/jenkins/jenkins:2.514 – 镜像下载 | docker.io

2)创建jenkens容器

docker run -d -p 8080:8080 -p 50000:50000 -v /home/wy/jenkins:/var/jenkins_home --name jenkins registry.cn-shenzhen.aliyuncs.com/xielincai/devops:jenkins_lts

参数说明:

-p 8080:8080:jenkins 访问端口

-v:将容器的目录挂载到宿主机上

–name:容器名

3)获取初始密码

# 进入容器
docker exec -it jenkins /bin/bash 

# 获取密码
cat /var/lib/jenkins/secrets/initialAdminPassword

4)网页访问jenkins

访问方式:IP地址 + 8080

备注:

部署过程中遇到问题,可联系站长获取帮助,博客首页选择对应的技术支持。Home – STARBUCKET

Docker builds GitLab

1)拉取最新gitlab镜像

docker pull  registry.cn-shenzhen.aliyuncs.com/xielincai/devops:gitlab

2)创建gitlab 容器

docker run -id -p 81:80 -p 9922:22 -v /root/gitlab/etc:/etc/gitlab -v /root/gitlab/log:/var/log/gitlab  -v /root/gitlab/opt:/var/opt/gitlab --restart=always --privileged=true --name gitlab registry.cn-shenzhen.aliyuncs.com/xielincai/devops:gitlab

参数说明:

-p 81:80:80为gitlab的访问端口,映射成宿主机的81

-p 9922:22:22为gitlab的ssh端口,如果用ssh拉取代码就需要这个

-v :将容器里的配置挂载到宿主机上

–restart=always:开机启动

–privileged=true:特权模式,赋予容器几乎与主机相同的权限

–name gitlab:自定义容器名

registry.cn-shenzhen.aliyuncs.com/xielincai/devops:gitlab:启动镜像

3)修改gitlab 配置文件

# 进入容器
docker exec -it gitlab /bin/bash

# 修改gitlab.rb
vi/etc/gitlab/gitlab.rb

# 找到变量改成对应的配置
external_url 'http://ip'

gitlab_rails['gitlab_ssh_host']='ip'

gitlab_rails['gitlab_shell_ssh_port']=9922

# 刷新配置
gitlab-ctlreconfigure

# 修改gitlab.yml
vi/opt/gitlab/embedded/service/gitlab-rails/config/gitlab.yml

gitlab:
    host: ip
    port: 81 # 这里改为81
    https: false

# 重启
gitlab-ctlrestart

# 获取gitlab初始密码
/etc/gitlab/initial_root_password

ubuntu/Centos 软件源

1)ubuntu阿里源

cat > /etc/apt/sources.list << EOF

deb https://mirrors.aliyun.com/ubuntu/ noble main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ noble main restricted universe multiverse

deb https://mirrors.aliyun.com/ubuntu/ noble-security main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ noble-security main restricted universe multiverse

deb https://mirrors.aliyun.com/ubuntu/ noble-updates main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ noble-updates main restricted universe multiverse

# deb https://mirrors.aliyun.com/ubuntu/ noble-proposed main restricted universe multiverse
# deb-src https://mirrors.aliyun.com/ubuntu/ noble-proposed main restricted universe multiverse

deb https://mirrors.aliyun.com/ubuntu/ noble-backports main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ noble-backports main restricted universe multiverse

EOF
sudo apt update

2)Centos阿里源

[base]
name=CentOS-$releasever - Base - mirrors.aliyun.com
baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

[updates]
name=CentOS-$releasever - Updates - mirrors.aliyun.com
baseurl=http://mirrors.aliyun.com/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

[extras]
name=CentOS-$releasever - Extras - mirrors.aliyun.com
baseurl=http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

[centosplus]
name=CentOS-$releasever - Plus - mirrors.aliyun.com
baseurl=http://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
sudo yum update

Self-Signed Certificate

1)windows/Linux 安装 OpenSSL

openssl genrsa -out ca/ca.key 4096
openssl req -x509 -new -nodes -sha512 -days 3650 
-subj "/C=CN/ST=Beijing/L=Beijing/O=devops/OU=Personal/CN=devops.com" 
-key ca.key 
-out ca.crt
openssl genrsa -out linux.devops.com.key 4096
openssl req -sha512 -new 
-subj "/C=CN/ST=Beijing/L=Beijing/O=devops/OU=Personal/CN=linux.devops.com" 
    -key linux.devops.com.key 
    -out linux.devops.com.csr
cat > v3.ext <<-EOF
authorityKeyIdentifier=keyid,issuer
basicConstraints=CA:FALSE
keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment
extendedKeyUsage = serverAuth
subjectAltName = @alt_names
[alt_names]
DNS.1=devops.com
DNS.2=devops
DNS.3=linux.devops.com
EOF
openssl x509 -req -sha512 -days 3650 
    -extfile v3.ext 
    -CA ca.crt -CAkey ca.key -CAcreateserial 
    -in linux.devops.com.csr 
    -out linux.devops.com.crt

2)嫌麻烦可以使用在线自签生成器

在线地址:https://bkssl.com/ssl/selfsign

备注:此网站为第三方网站,有任何侵权风险均与本人无关!