首页
博客小事纪
网站统计
友情链接
推荐
百度一下
文心一言
通义千问
Search
1
基于 openEuler 操作系统的 VNC(noVNC) 部署流程
476 阅读
2
openEuler 操作系统用户权限管理——sudo 权限的授予与限制案例
422 阅读
3
基于 openEuler 操作系统使用 Sealos 构建 Kubernetes 高可用集群
347 阅读
4
openEuler 搭建本地 repo 源
266 阅读
5
基于 openEuler 22.03 LTS SP4 编译 docker 20.10.13
139 阅读
默认分类
openEuler
x2openEuler
云原生
生活随笔
登录
Search
标签搜索
openEuler
Docker
故宫
kubernetes
x2openEuler
Nginx
repo
VNC
SUSE
DeepSeek
Ollama
AI
闫志聪
累计撰写
17
篇文章
累计收到
0
条评论
首页
栏目
默认分类
openEuler
x2openEuler
云原生
生活随笔
页面
博客小事纪
网站统计
友情链接
推荐
百度一下
文心一言
通义千问
搜索到
17
篇与
的结果
2023-08-20
如何免费签发 HTTPS 证书
1 背景在网站服务中,使用 HTTPS 协议可以有效提高安全性,但是需要进行证书的签发。对于大型的网站服务是非常容易的,但对于如个人博客网站等,需要承担一定的证书签发费用。本文主要提供两种免费签发 HTTPS 证书的方法,供大家学习交流。2 使用 certbot 生成证书2.1 生成证书(1)安装 certbot# 安装 epel-release 源 $ yum -y install epel-release # 安装 certbot $ yum -y install certbot(2)生成泛域名 *.ecsy.top 证书# 执行以下命令 $ certbot certonly -d *.ecsy.top --manual --preferred-challenges dns 参数释义: -d 指定您的泛域名 --manual 表示手动生成证书 --pfeferred-challeges dns 使用 DNS 验证域名归属(3)此处输入您的邮箱地址Saving debug log to /var/log/letsencrypt/letsencrypt.log Enter email address (used for urgent renewal and security notices) (Enter 'c' to cancel): xxxxxx@126.com(4)输入 Y 同意Please read the Terms of Service at https://letsencrypt.org/documents/LE-SA-v1.3-September-21-2022.pdf. You must agree in order to register with the ACME server. Do you agree? - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - (Y)es/(N)o: Y(5)输入 N 不允许共享电子邮件地址Would you be willing, once your first certificate is successfully issued, to share your email address with the Electronic Frontier Foundation, a founding partner of the Let's Encrypt project and the non-profit organization that develops Certbot? We'd like to send you email about our work encrypting the web, EFF news, campaigns, and ways to support digital freedom. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - (Y)es/(N)o: N(6)根据提示进行域名归属认证Account registered. Requesting a certificate for *.ecsy.top - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Please deploy a DNS TXT record under the name: _acme-challenge.ecsy.top. with the following value: aQyGqKJecDh9ud-TuQlH-N70DW_RF6KtBRx_EZ0vhLI Before continuing, verify the TXT record has been deployed. Depending on the DNS provider, this may take some time, from a few seconds to multiple minutes. You can check if it has finished deploying with aid of online tools, such as the Google Admin Toolbox: https://toolbox.googleapps.com/apps/dig/#TXT/_acme-challenge.ecsy.top. Look for one or more bolded line(s) below the line ';ANSWER'. It should show the value(s) you've just added. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Press Enter to Continue根据返回信息提示,在您的域名提供商控制台,添加一条 DNS TXT 解析记录:注意:添加 DNS 解析记录后,需要等待一段时间进行同步,才能解析成功,可以使用 nslookup -q=TXT _acme-challenge.test.com. 尝试解析,或在域名提供商控制台进行生效检测。检测成功后,按 Enter 键继续。(7)成功签发证书Successfully received certificate. Certificate is saved at: /etc/letsencrypt/live/ecsy.top/fullchain.pem Key is saved at: /etc/letsencrypt/live/ecsy.top/privkey.pem This certificate expires on 2024-01-06. These files will be updated when the certificate renews.# 查看证书文件 $ ls /etc/letsencrypt/live/ecsy.top/ fullchain.pem # 证书 privkey.pem # 私钥2.2 将证书添加到 Web 服务配置文件中# 此处使用 nginx $ vim /etc/nginx/nginx.conf server { listen 443 ssl http2; ssl_certificate "/etc/letsencrypt/live/ecsy.top/fullchain.pem"; ssl_certificate_key "/etc/letsencrypt/live/ecsy.top/privkey.pem"; ...... }2.3 常见问题2.3.1 仍然提示连接不安全在配置好证书后访问网站时,可能仍然出现连接不安全的提示,如下图所示:原因已经说的非常清楚了,此处我使用 escy.top 这个域名来访问,并没有使用泛域名,因此提示:“此服务器无法证明它是 ecsy.top;它的安全证书来自 *.ecsy.top。这可能是由错误配置或者有攻击者截获你的连接而导致的。”为此,我们需要再次为 ecsy.top 生成证书,重新执行上文所述的证书生成步骤并配置到 Web 服务中即可,此时的生成证书命令将变为:# 执行以下命令 $ certbot certonly -d ecsy.top --manual --preferred-challenges dns2.3.2 证书有效期证书有效期为 3 个月,证书到期前您可以手动按以上步骤重新签发,也可以使用官方提供的自动续期方案。NEXT STEPS: - This certificate will not be renewed automatically. Autorenewal of --manual certificates requires the use of an authentication hook script (--manual-auth-hook) but one was not provided. To renew this certificate, repeat this same certbot command before the certificate's expiry date.3 使用图形化界面生成证书如果您觉得使用 certbot 命令行工具生成证书比较繁琐,且不直观,可以使用网页来生成证书。比较推荐这个网站:来此加密 - Let's Encrypt 在线免费申请SSL证书 (osfipin.com):此网站有如下特点:提供了直观的操作界面,引导流程也非常详细易懂。其原理与 certbot 命令行工具类似,都需要使用 DNS TXT 记录来验证域名的归属。在证书生成后,可以进行下载使用。证书有效期仍然是 3 个月,可以选择到期前通过短信提醒,重新续期。可以在账户中方便管理自己的证书。由于操作难度不大,在此不作流程演示。
2023年08月20日
57 阅读
0 评论
3 点赞
2023-06-11
Docker 安装脚本
1 背景Docker 官方网站的说明文档中,介绍了在各种 Linux 发行版系统上安装 Docker 的步骤及各种安装方法。例如,在 CentOS 上安装 Docker 可以参考:Install Docker Engine on CentOS | Docker Docs。众所周知,此网站在国内难以访问,当然也可以使用国内可用的 Yum 源。但总体的安装、配置步骤比较繁琐,尤其是在新旧版本切换时,常因为某些文件、目录未彻底清理,导致 Docker 启动失败。此脚本具有下功能:提供 docker-ce-17.03.0 版本和 docker-ce 最新稳定版的安装部署可以实现 dokcer-ce-17.03.0 版本和 docker-ce 最新稳定版的无缝切换安装,无需重启系统可以自动解决网桥与防火墙的连接问题,安装后无需重启系统若安装后存储驱动不是 overlay(overlay2),提供一键解决方案的选择内置初始化代码(默认启用,停用需要自己编辑),若您的 Docker 出现问题,不妨用此脚本重新安装说明:因为旧版本的 Docker(如 docker-ce-17.03.0)在执行命令后有比较详细完整的返回结果,适合学习使用,因此脚本提供旧版本的一键安装。{dotted startColor="#7d7dfa" endColor="#7d7dfa"/}2 Docker 一键安装脚本# 脚本创建:闫志聪 # 创建时间:2023-09-15 # 当前版本:v2 #!/bin/bash trap 'mytrap ; exit 1' SIGINT INT # 声明初始化及中断善后函数 function mytrap() { yum -y remove containerd.io docker-buildx-plugin docker-ce docker-ce-cli docker-compose-plugin docker-ce-selinux.noarch \ audit-libs-python checkpolicy container-selinux.noarch docker-ce-rootless-extras fuse-overlayfs \ fuse3-libs libcgroup libsemanage-python policycoreutils-python python-IPy.noarch setools-libs slirp4netns rm -rf /root/docker-ce rm -rf /etc/docker rm -rf /var/lib/docker # rm -rf /etc/yum.repos.d/docker-ce.repo rm -rf /etc/sysctl.d/bridge-iptables.conf # rm -rf /proc/sys/net/bridge/bridge-nf-call-iptables # rm -rf /proc/sys/net/bridge/bridge-nf-call-ip6tables } # 安装 docker-ce-17.03.0 版本 function docker-ce-old () { mkdir /root/docker-ce && cd /root/docker-ce echo -e "\e[0;31m" curl -O https://download.docker.com/linux/centos/7/x86_64/stable/Packages/docker-ce-17.03.0.ce-1.el7.centos.x86_64.rpm echo curl -O https://download.docker.com/linux/centos/7/x86_64/stable/Packages/docker-ce-selinux-17.03.0.ce-1.el7.centos.noarch.rpm echo -e "\e[0m" yum -y install docker-ce-17.03.0.ce-1.el7.centos.x86_64.rpm docker-ce-selinux-17.03.0.ce-1.el7.centos.noarch.rpm rm -rf /root/docker-ce if [ ! -d /etc/docker ] ; then mkdir /etc/docker ; fi } # 安装 docker-ce 最新版本 function docker-ce-latest () { yum -y install yum-utils echo -e "\e[0;31m" yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo echo -e "\e[0m" yum --enablerepo=docker-ce-stable -y install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin if [ ! -d /etc/docker ] ; then mkdir /etc/docker ; fi } # 声明选项判断函数 function option_check () { if [ "$1"=="number" ] ; then flag=$(echo $2 | egrep "1|2") elif [ "$1"=="letter" ] ; then flag=$(echo $2 | egrep "y|n") fi [ -z "$flag" ] && echo -e "\e[1;31m选项输入错误,请重新输入\e[0m" || break } # 版本选择 echo -n -e "\e[0;31m" cat <<EOF 请选择需要安装的 docker-ce 版本: 1、docker-ce-17.03.0 2、docker-ce-latest EOF while true ; do read -p "请输入您的选项:" num ; option_check number $num ; done echo -n -e "\e[0m" # 初始化安装环境 mytrap # 开始安装 case $num in 1) docker-ce-old ;; 2) docker-ce-latest ;; esac # 设置镜像加速站点 while true ; do echo -n -e "\e[0;31m" read -p "请输入您的Docker加速站点:" mirror echo -n -e "\e[0m" [ -z "$mirror" ] && mirror="https://fv6z6xq3.mirror.aliyuncs.com" url=${mirror#*//} ping -c 4 $url 2>/dev/null [ "$?" -ne 0 ] && echo -e "\e[1;31m加速站点不可用,请重新输入\e[0m" || break done cat > /etc/docker/daemon.json <<EOF { "registry-mirrors": ["$mirror"] } EOF # 解决 bridge 和 iptables 的连接问题 echo "1" > /proc/sys/net/bridge/bridge-nf-call-iptables echo "1" > /proc/sys/net/bridge/bridge-nf-call-ip6tables echo "net.bridge.bridge-nf-call-iptables=1" > /etc/sysctl.d/bridge-iptables.conf echo "net.bridge.bridge-nf-call-ip6tables=1" >> /etc/sysctl.d/bridge-iptables.conf #echo -e "\e[0;31m" #sysctl -p /etc/sysctl.d/bridge-iptables.conf #echo -e "\e[0m" systemctl enable docker systemctl start docker run=$(systemctl status docker | grep "active (running)") mirror=$(docker info | grep -A 1 "Registry Mirrors" | grep -v "Registry Mirrors") ufs=$(docker info | grep "Storage Driver" | grep overlay) if [ -z "$run" ] ; then echo -e "\e[0;31mDocker未启动\e[0m" exit 2 elif [ -n "$run" -a -n "$ufs" ] ; then echo -e "Docker运行正常:\e[0;32m$run\e[0m" echo -e "Docker加速站点:\e[0;34m $mirror\e[0m" echo -e "Docker存储驱动:\e[0;31m $ufs\e[0m" exit 0 elif [ -n "$run" -a -z "$ufs" ] ; then echo -e "Docker运行正常:\e[0;32m$run\e[0m" echo -e "Docker加速站点:\e[0;34m $mirror\e[0m" echo -e "\e[0;31mDocker文件系统不是overlay\e[0m" echo -n -e "\e[0;31m" while true ; do read -p "是否修正UFS类型为overlay,y(是),n(否):" let ; option_check letter $let ; done echo -e "\e[0m" case $let in y) echo "overlay" > /etc/modules-load.d/overlay.conf sed -i '/ExecStart/c ExecStart=/usr/bin/dockerd --storage-driver=overlay' systemctl daemon-reload systemctl restart docker ufs1=$(docker info | grep "Storage Driver" | grep overlay) echo -e "Docker存储驱动已修正:\e[0;31m$ufs1\e[0m" exit 0 ;; n) exit 2 ;; esac fi{dotted startColor="#7d7dfa" endColor="#7d7dfa"/}3 使用说明请填写正确的镜像加速站点,不要用脚本中默认的,那是我自己用的!!!若对脚本使用过程有疑问,或脚本执行错误、有更好的意见等,可在后台留言您也可以直接点击此处下载脚本文件:docker-ce-install.sh
2023年06月11日
84 阅读
0 评论
5 点赞
1
...
3
4