-
Notifications
You must be signed in to change notification settings - Fork 0
feat: 添加certbot自动更新证书的配置 #28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
ad3a6cf
wip: 添加certbot
ipcjs e027965
wip: 尝试改成执行脚本
ipcjs 250c1e7
wip: 使用Dockerfile给certbot的容器添加docker compose命令
ad0f353
wip: 添加过期提醒邮箱
fe78100
wip: email参数不支持=分隔
9e417e4
fix: 规范ini文件格式
85cf31d
wip: 添加自动申请证书的demo和说明
80bbb05
wip: 重启所有包含nginx的服务
abcac17
wip: 优化日志
ccb7160
wip: 也申请VIDEO_HOSTNAME域名
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| ../.env.default |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| # 支持100+DNS提供商的Certbot插件 | ||
| # 详见: https://github.com/alexzorin/certbot-dns-multi | ||
| FROM ghcr.io/alexzorin/certbot-dns-multi:4.27.0 | ||
|
|
||
| # 添加docker和docker compose命令 | ||
| COPY --from=docker:cli /usr/local/bin/docker /usr/local/bin/docker | ||
| COPY --from=docker:cli /usr/local/libexec/docker/cli-plugins/docker-compose /usr/local/libexec/docker/cli-plugins/docker-compose |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| services: | ||
| certbot: | ||
| build: . | ||
| command: | ||
| - certonly | ||
| - --non-interactive | ||
| - --agree-tos | ||
| - ${CERTBOT_EMAIL:-transcodegroupdeveloper@gmail.com} | ||
| - --authenticator=dns-multi | ||
| - --dns-multi-credentials=/etc/letsencrypt/dns-multi.ini | ||
| # 四个域名可以同时申请, 故不要求必填 | ||
| - --domains=${SERVER_HOSTNAME} | ||
| - --domains=${TRACK_HOSTNAME} | ||
xiaorongnie marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| - --domains=${BUS_HOSTNAME} | ||
| - --domains=${VIDEO_HOSTNAME} | ||
| - --deploy-hook | ||
| - "sh -c 'COMPOSE_PROJECT_NAME=${COMPOSE_PROJECT_NAME} DATA=${DATA_DIR:-/data} /home/docker/certbot/deploy-hook.sh'" | ||
| volumes: | ||
| - /var/run/docker.sock:/var/run/docker.sock | ||
| - ${DATA_DIR:-/data}/certbot:/etc/letsencrypt | ||
| configs: | ||
| - source: certbot-deploy-hook.sh | ||
| target: /home/docker/certbot/deploy-hook.sh | ||
| - source: certbot-dns-multi.ini | ||
| target: /etc/letsencrypt/dns-multi.ini | ||
| mode: 0600 | ||
|
|
||
|
|
||
| ofelia: | ||
| image: mcuadros/ofelia | ||
| command: daemon --docker | ||
| volumes: | ||
| - /var/run/docker.sock:/var/run/docker.sock:ro | ||
| labels: | ||
| # 通过ofelia重启其他服务, 需要这样绕一道 | ||
| # https://github.com/mcuadros/ofelia/issues/280#issuecomment-2561863012 | ||
| ofelia.job-run.certbot-renew.schedule: "@daily" | ||
| ofelia.job-run.certbot-renew.command: "sh -c 'docker compose -p ${COMPOSE_PROJECT_NAME} restart certbot'" | ||
| ofelia.job-run.certbot-renew.image: "docker:cli" | ||
| ofelia.job-run.certbot-renew.volume: "/var/run/docker.sock:/var/run/docker.sock" | ||
|
|
||
| configs: | ||
| certbot-deploy-hook.sh: | ||
| file: ./deploy-hook.sh | ||
| # certbot-dns-multi的配置文件 | ||
| # https://github.com/alexzorin/certbot-dns-multi#usage | ||
| certbot-dns-multi.ini: | ||
| content: | | ||
| dns_multi_provider = ${CERTBOT_DNS_PROVIDER:-dnspod} | ||
| DNSPOD_API_KEY = "${CERTBOT_DNS_API_KEY:?required}" | ||
| CLOUDFLARE_DNS_API_TOKEN = "${CERTBOT_DNS_API_KEY:?required}" | ||
| TENCENTCLOUD_SECRET_KEY = "${CERTBOT_DNS_API_KEY:?required}" | ||
| TENCENTCLOUD_SECRET_ID = "${CERTBOT_TENCENTCLOUD_SECRET_ID}" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| #!/bin/sh | ||
| set -e | ||
|
|
||
| cp -f "$RENEWED_LINEAGE/fullchain.pem" "$RENEWED_LINEAGE/certificate.crt" | ||
xiaorongnie marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| cp -f "$RENEWED_LINEAGE/privkey.pem" "$RENEWED_LINEAGE/certificate.key" | ||
|
|
||
| echo "======================" | ||
| echo "请将证书变量设置为:" | ||
| echo "SSL_CERTIFICATE='${DATA_DIR:-/data}/certbot/live/$(basename "$RENEWED_LINEAGE")/certificate'" | ||
| echo | ||
|
|
||
| echo "正在查找包含'nginx'的服务..." | ||
| nginx_services=$(docker compose -p "${COMPOSE_PROJECT_NAME}" ps --services | grep nginx || true) | ||
|
|
||
| if [ -n "$nginx_services" ]; then | ||
| echo "重启 $nginx_services 中..." | tr '\n' ' ' | ||
| echo | ||
| echo "$nginx_services" | xargs docker compose -p "${COMPOSE_PROJECT_NAME}" restart | ||
| echo "重启完成" | ||
| else | ||
| echo "未找到包含'nginx'的服务" | ||
| fi | ||
| echo "======================" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,22 +1,24 @@ | ||
| #---------服务器信息, 必须按实际服务器信息填写----------------- | ||
| ## 公网IP | ||
| ##---------服务器信息, 必须按实际服务器信息填写----------------- | ||
| # 公网IP | ||
| SERVER_IP_PUBLIC='81.71.36.80' | ||
| ## HOSTNAME 没有用域名IP替代 | ||
| # HOSTNAME 没有用域名IP替代 | ||
| SERVER_HOSTNAME='transcodegroup.cn' | ||
| ## SSL证书 | ||
| SSL_CERTIFICATE='/home/docker-compose/ssl/tg_com' | ||
| # 自动申请的SSL证书 | ||
| SSL_CERTIFICATE="/data/certbot/live/${SERVER_HOSTNAME}/certificate" | ||
| # dnspod的api key, 由id和token拼接而成: https://console.dnspod.cn/account/token/token | ||
| CERTBOT_DNS_API_KEY='id,token' | ||
|
|
||
| #---------自定义初始密码, 建议随机生成新的替换------------- | ||
| ## MYSQL, 必填 | ||
| ##---------自定义初始密码, 建议随机生成新的替换------------- | ||
| # MYSQL, 必填 | ||
| MYSQL_PASSWORD='ZfJwfEJvL8wbPr4LvCyx' | ||
| ## REDIS, 必填 | ||
| # REDIS, 必填 | ||
| REDIS_PASSWORD='ZfJwfEJvL8wbPr4LvCyx' | ||
| ## RABBIT_MQ, 必填 | ||
| # RABBIT_MQ, 必填 | ||
| RABBITMQ_PASSWORD='ZfJwfEJvL8wbPr4LvCyx' | ||
| ## Email,必填 | ||
| # Email,必填 | ||
| MAIL_PASSWORD='ZfJwfEJvL8wbPr4LvCyx' | ||
|
|
||
| #----------自定义端口信息, 推荐开放9000~9100,443,80-------- | ||
| ##----------自定义端口信息, 推荐开放9000~9100,443,80-------- | ||
| # 前端端口配置, HTTP默认80, HTTPS默认443 | ||
| WEB_PORT_HTTP=9070 | ||
| WEB_PORT_HTTPS=9080 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.