<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[AbelのBlog]]></title><description><![CDATA[👋欢迎来到我的小世界~]]></description><link>https://joyabel.top</link><image><url>https://joyabel.top/innei.svg</url><title>AbelのBlog</title><link>https://joyabel.top</link></image><generator>Shiro (https://github.com/Innei/Shiro)</generator><lastBuildDate>Sun, 31 May 2026 06:02:32 GMT</lastBuildDate><atom:link href="https://joyabel.top/feed" rel="self" type="application/rss+xml"/><pubDate>Sun, 31 May 2026 06:02:32 GMT</pubDate><language><![CDATA[zh-CN]]></language><item><title><![CDATA[阿里云服务器使用 Let's Encrypt 配置 SSL 证书]]></title><description><![CDATA[<div><blockquote>该渲染由 Shiro API 生成，可能存在排版问题，最佳体验请前往：<a href="https://joyabel.top/posts/frontend/letsencrypt">https://joyabel.top/posts/frontend/letsencrypt</a></blockquote><div><h1 id="-lets-encrypt--ssl-">阿里云服务器使用 Let&#x27;s Encrypt 配置 SSL 证书</h1><h2 id="">一、准备工作</h2><h3 id="1-">1. 确保满足条件</h3><ul><li>拥有域名（如 example.com）</li><li>域名已解析到阿里云服务器 IP</li><li>服务器已安装 Nginx/Apache</li><li>80/443 端口已开放</li></ul><h3 id="2-">2. 检查网络和防火墙</h3><pre class="language-shell lang-shell"><code class="language-shell lang-shell"># 阿里云安全组开放端口
# 控制台 → 安全组 → 配置规则 → 添加规则
# 端口：80, 443
# 授权对象：0.0.0.0/0

# 服务器防火墙
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw reload
# 或
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload
</code></pre>
<h2 id="-certbot">二、安装 Certbot</h2><h3 id="1--snap-">1. 方法一：通过 snap 安装（推荐）</h3><pre class="language-shell lang-shell"><code class="language-shell lang-shell"># 安装 snap
sudo apt update
sudo apt install snapd -y

# 移除旧版本 certbot（如果有）
sudo apt remove certbot
sudo snap remove certbot

# 安装 snap core
sudo snap install core
sudo snap refresh core

# 安装 certbot
sudo snap install --classic certbot
sudo ln -s /snap/bin/certbot /usr/bin/certbot
</code></pre>
<h3 id="2-">2. 方法二：通过包管理器安装</h3><pre class="language-shell lang-shell"><code class="language-shell lang-shell"># Ubuntu/Debian
sudo apt update
sudo apt install certbot python3-certbot-nginx -y

# CentOS/RHEL
sudo yum install epel-release -y
sudo yum install certbot python3-certbot-nginx -y
</code></pre>
<h2 id="-ssl-">三、获取 SSL 证书</h2><h3 id="1--nginx-">1. 使用 Nginx 插件自动配置（最简便）</h3><pre class="language-shell lang-shell"><code class="language-shell lang-shell"># 自动获取并配置证书
sudo certbot --nginx -d example.com -d www.example.com

# 多个域名
sudo certbot --nginx \
  -d example.com \
  -d www.example.com \
  -d api.example.com \
  -d blog.example.com
</code></pre>
<p><strong>交互过程提示：</strong></p><ol start="1"><li>输入邮箱（接收续期提醒）</li><li>同意服务条款</li><li>是否分享邮箱（可选）</li><li>选择为哪些虚拟主机配置 HTTPS</li><li>是否自动将所有 HTTP 重定向到 HTTPS（推荐选择 2）</li></ol><h3 id="2-">2. 仅获取证书（手动配置）</h3><pre class="language-shell lang-shell"><code class="language-shell lang-shell"># 仅获取证书，不修改配置
sudo certbot certonly --nginx \
  -d example.com \
  -d www.example.com
</code></pre>
<p><strong>证书位置：</strong></p><pre class="language-shell lang-shell"><code class="language-shell lang-shell">/etc/letsencrypt/live/example.com/
├── cert.pem       # 证书文件
├── chain.pem      # 中间证书
├── fullchain.pem  # 完整证书链
└── privkey.pem    # 私钥文件
</code></pre>
<h2 id="nginx--ssl">四、Nginx 手动配置 SSL</h2><p>如果选择手动配置，在 Nginx 配置中添加：</p><pre class="language-shell lang-shell"><code class="language-shell lang-shell">server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name example.com www.example.com;
    
    # SSL 证书路径
    ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
    
    # SSL 优化配置
    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
    ssl_prefer_server_ciphers on;
    ssl_session_cache shared:SSL:10m;
    ssl_session_timeout 10m;
    
    root /var/www/example.com/html;
    index index.html index.htm;
    
    location / {
        try_files $uri $uri/ =404;
    }
}

# HTTP 重定向到 HTTPS
server {
    listen 80;
    listen [::]:80;
    server_name example.com www.example.com;
    return 301 https://$server_name$request_uri;
}
</code></pre>
<h2 id="">五、自动续期配置</h2><h3 id="1-">1. 测试续期</h3><pre class="language-shell lang-shell"><code class="language-shell lang-shell"># 测试续期（不实际执行）
sudo certbot renew --dry-run
</code></pre>
<h3 id="2-">2. 自动续期配置</h3><p>Let&#x27;s Encrypt 证书有效期为 90 天，需要定期续期。</p><pre class="language-shell lang-shell"><code class="language-shell lang-shell"># 查看定时任务
sudo systemctl list-timers

# 手动测试续期
sudo certbot renew
</code></pre>
<h3 id="3-">3. 添加自动续期脚本</h3><pre class=""><code class=""># 创建续期脚本
sudo nano /etc/cron.daily/certbot-renew
</code></pre>
<p>脚本内容：</p><pre class="language-shell lang-shell"><code class="language-shell lang-shell">#!/bin/bash
certbot renew --quiet --post-hook &quot;systemctl reload nginx&quot;
</code></pre>
<p>设置权限：</p><pre class="language-shell lang-shell"><code class="language-shell lang-shell">sudo chmod +x /etc/cron.daily/certbot-renew
</code></pre>
<h3 id="4--systemd-">4. 使用 systemd 定时任务</h3><pre class="language-shell lang-shell"><code class="language-shell lang-shell"># 查看现有定时任务
sudo systemctl list-timers | grep certbot

# 手动运行续期
sudo certbot renew
</code></pre>
<h2 id="">六、证书管理命令</h2><h3 id="1-">1. 常用命令</h3><pre class="language-shell lang-shell"><code class="language-shell lang-shell"># 查看证书信息
sudo certbot certificates

# 删除证书
sudo certbot delete --cert-name example.com

# 修改证书（添加/删除域名）
sudo certbot --nginx -d example.com -d www.example.com -d newsub.example.com

# 强制更新证书
sudo certbot renew --force-renewal
</code></pre>
<h3 id="2-">2. 证书文件位置</h3><pre class="language-shell lang-shell"><code class="language-shell lang-shell"># 证书文件路径
/etc/letsencrypt/live/example.com/

# 所有存档
/etc/letsencrypt/archive/example.com/

# 配置
/etc/letsencrypt/renewal/example.com.conf
</code></pre>
<h2 id="">七、高级配置</h2><h3 id="1--dns-">1. 通配符证书（需要 DNS 验证）</h3><pre class="language-shell lang-shell"><code class="language-shell lang-shell"># 安装 DNS 插件
sudo snap set certbot trust-plugin-with-root=ok
sudo snap install certbot-dns-aliyun

# 获取阿里云 DNS API 密钥
# 阿里云控制台 → RAM 访问控制 → 创建用户（授权 AliyunDNSFullAccess）
# 获取 AccessKey ID 和 Secret

# 创建配置文件
sudo mkdir -p /etc/letsencrypt
sudo nano /etc/letsencrypt/aliyun.ini
</code></pre>
<p><code>aliyun.ini</code>内容：</p><pre class="language-shell lang-shell"><code class="language-shell lang-shell">dns_aliyun_access_key = YOUR_ACCESS_KEY_ID
dns_aliyun_access_key_secret = YOUR_ACCESS_KEY_SECRET
</code></pre>
<p>获取通配符证书：</p><pre class=""><code class="">sudo certbot certonly \
  --authenticator dns-aliyun \
  --dns-aliyun-credentials /etc/letsencrypt/aliyun.ini \
  -d &quot;*.example.com&quot; \
  -d example.com
</code></pre>
<h3 id="2--docker-">2. 使用 Docker 获取证书</h3><pre class="language-shell lang-shell"><code class="language-shell lang-shell"># 拉取 certbot 镜像
docker pull certbot/certbot

# 运行 certbot
docker run -it --rm \
  -v /etc/letsencrypt:/etc/letsencrypt \
  -v /var/lib/letsencrypt:/var/lib/letsencrypt \
  -p 80:80 \
  certbot/certbot certonly --standalone -d example.com
</code></pre>
<h2 id="nginx-ssl-">八、Nginx SSL 优化配置</h2><pre class="language-shell lang-shell"><code class="language-shell lang-shell">server {
    listen 443 ssl http2;
    
    ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
    
    # 优化配置
    ssl_session_timeout 1d;
    ssl_session_cache shared:SSL:50m;
    ssl_session_tickets off;
    
    # 现代配置
    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
    ssl_prefer_server_ciphers off;
    
    # HSTS (可选，谨慎开启)
    add_header Strict-Transport-Security &quot;max-age=63072000&quot; always;
    
    # OCSP Stapling
    ssl_stapling on;
    ssl_stapling_verify on;
    ssl_trusted_certificate /etc/letsencrypt/live/example.com/chain.pem;
    resolver 8.8.8.8 8.8.4.4 valid=300s;
    resolver_timeout 5s;
}
</code></pre>
<h2 id="">九、常见问题解决</h2><h3 id="1--80-">1. 端口 80 被占用</h3><pre class="language-shell lang-shell"><code class="language-shell lang-shell"># 检查占用
sudo lsof -i :80
sudo netstat -tulnp | grep :80

# 停止占用程序或修改 Nginx 配置
</code></pre>
<h3 id="2-">2. 证书续期失败</h3><pre class="language-shell lang-shell"><code class="language-shell lang-shell"># 检查错误日志
sudo tail -f /var/log/letsencrypt/letsencrypt.log

# 手动调试
sudo certbot renew --debug
</code></pre>
<h3 id="3-">3. 阿里云安全组配置</h3><p>确保安全组规则包含：</p><ul><li>入方向：80/tcp, 443/tcp</li><li>出方向：无限制</li></ul><h3 id="4-">4. 验证证书</h3><pre class="language-shell lang-shell"><code class="language-shell lang-shell"># 在线验证
curl -I https://example.com

# 查看证书信息
openssl s_client -connect example.com:443 -servername example.com
</code></pre>
<h2 id="">十、备份和恢复</h2><pre class="language-shell lang-shell"><code class="language-shell lang-shell"># 备份证书
sudo tar -czf letsencrypt-backup-$(date +%Y%m%d).tar.gz /etc/letsencrypt/

# 恢复证书
sudo tar -xzf letsencrypt-backup.tar.gz -C /
sudo systemctl reload nginx
</code></pre>
<p>完成以上步骤后，您的网站应该可以通过 HTTPS 访问，并显示安全锁标志。</p></div><p style="text-align:right"><a href="https://joyabel.top/posts/frontend/letsencrypt#comments">看完了？说点什么呢</a></p></div>]]></description><link>https://joyabel.top/posts/frontend/letsencrypt</link><guid isPermaLink="true">https://joyabel.top/posts/frontend/letsencrypt</guid><dc:creator><![CDATA[安]]></dc:creator><pubDate>Tue, 27 Jan 2026 06:08:20 GMT</pubDate></item><item><title><![CDATA[Docusaurus 使用文档]]></title><description><![CDATA[<div><blockquote>该渲染由 Shiro API 生成，可能存在排版问题，最佳体验请前往：<a href="https://joyabel.top/posts/frontend/docusaurus-doc">https://joyabel.top/posts/frontend/docusaurus-doc</a></blockquote><div><p>文档地址：https://docusaurus.io/zh-CN/docs</p><h3 id="-"><strong>一. 安装</strong></h3><p>node 版本 18.0 或者更高版本</p><h3 id=""><strong>二.使用脚手架生成站点</strong></h3><pre class="language-bash lang-bash"><code class="language-bash lang-bash">npx create-docusaurus@latest my-website classic  --typescript
</code></pre>
<h3 id="-">四. 项目结构</h3><pre class="language-bash lang-bash"><code class="language-bash lang-bash">my-website
├── blog ### 博客目录
│   ├── 2019-05-28-hola.md
│   ├── 2019-05-29-hello-world.md
│   └── 2020-05-30-welcome.md
├── docs ### 文档目录
│   ├── doc1.md
│   ├── doc2.md
│   ├── doc3.md
│   └── mdx.md
├── src
│   ├── css
│   │   └── custom.css
│   └── pages
│       ├── styles.module.css
│       └── index.js
├── static
│   └── img
├── docusaurus.config.js
├── package.json
├── README.md
├── sidebars.js
└── yarn.lock
</code></pre>
<p>注意📢：如果不想使用blog 和 docs 目录的情况下 可以删除掉 并且使用自定义页面路由的方式新建页面</p><h3 id="-"><strong>五. 运行</strong></h3><pre class="language-bash lang-bash"><code class="language-bash lang-bash">cd my-website
yarn start
</code></pre>
<h3 id="-">六. 新建自定义页面</h3><h3 id="1">1.使用第三方组件</h3><p>  例如新建<code>src/pages/navigation/index.tsx</code>页面</p><pre class="language-bash lang-bash"><code class="language-bash lang-bash">import React from &#x27;react&#x27;;
import Layout from &#x27;@theme/Layout&#x27;; 

export default function Navigation() {
  return (
    &lt;Layout title=&quot;导航&quot;&gt;
      Hello
    &lt;/Layout&gt;
  );
}

</code></pre>
<h3 id="2md">2.使用md文档自定义页面</h3><p>例如新建<code>src/pages/navigation/index.md</code> 文件</p><pre class="language-markdown lang-markdown"><code class="language-markdown lang-markdown"># My Markdown page

This is a Markdown page
</code></pre>
<p>启动项目，之后在<code>http://localhost:3000/navigation</code>就可以看到自己的导航页面了。自定义的页面没有自带网站布局样式，所以从<code>@theme/Layout</code>中导入<code>Layout</code>组件，使用网站统一的导航栏、页脚等。</p><p>然后在<code>Layout</code> 或者 <code>index.md</code>内编写自己的内容就好了。</p><p><strong>将新页面添加到导航栏</strong></p><p>修改<code>docusaurus.config.js</code>，添加自定义页面的路由。</p><pre class="language-bash lang-bash"><code class="language-bash lang-bash">...
const config = {
  ...
  themeConfig:
    ({
      navbar: {
        ...
        items: [
          {to: &#x27;/blog&#x27;, label: &#x27;Blog&#x27;, position: &#x27;left&#x27;},
          {type: &#x27;doc&#x27;, docId: &#x27;intro&#x27;, position: &#x27;left&#x27;, label: &#x27;Docs&#x27;},
          // highlight-start
          {
            to: &#x27;/navigation&#x27;,
            position: &#x27;left&#x27;,
            label: &#x27;导航&#x27;,
          },
          // highlight-end
          {href: &#x27;https://github.com/ddupg&#x27;, label: &#x27;GitHub&#x27;, position: &#x27;right&#x27;},
        ],
      },
      ...
    }),
};

</code></pre>
<p>再刷新页面，导航栏上就会出现自定义的页面了。</p></div><p style="text-align:right"><a href="https://joyabel.top/posts/frontend/docusaurus-doc#comments">看完了？说点什么呢</a></p></div>]]></description><link>https://joyabel.top/posts/frontend/docusaurus-doc</link><guid isPermaLink="true">https://joyabel.top/posts/frontend/docusaurus-doc</guid><dc:creator><![CDATA[安]]></dc:creator><pubDate>Mon, 19 Jan 2026 05:44:48 GMT</pubDate></item></channel></rss>