我用nginx的是代理服务器。我的应用程序有一个功能,用户可以使用自己的域而不是我的域。为此,他们需要将其 CNAME 指向我的域。
这是我的 Nginx 配置
server {
server_name scan.mydomain.com anonymous.mydomain.com "";
access_log /etc/nginx/log/local-wc.access.log;
error_log /etc/nginx/log/local-wc.error.log;
location / {
root /var/www/html/qcg-scanning-frontend/dist/webapp/;
index index.html;
try_files $uri $uri/ /index.html;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Protocol $scheme;
}
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/anonymous.mydomain.com-0001/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/anonymous.mydomain.com-0001/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
if ($host …Run Code Online (Sandbox Code Playgroud) 我收到 certbot 的错误消息,表示在尝试创建证书时连接被拒绝。我检查了 DNS 条目,它具有正确的服务器 IP。
当我尝试调用该域时,浏览器也显示连接被拒绝。我猜至少 nginx 应该正确运行并显示 wordpress ?为什么我的连接被拒绝?
MPORTANT NOTES:
certbot | - The following errors were reported by the server:
certbot |
certbot | Domain: retronexus.net
certbot | Type: connection
certbot | Detail: Fetching
certbot | http://retronexus.net/.well-known/acme-challenge/YQzSQsdAAhqG45A5xAL3tJ4dMrsmTVfcKQVGNzT1lvs:
certbot | Connection refused
certbot |
certbot | Domain: www.retronexus.net
certbot | Type: connection
certbot | Detail: Fetching
certbot | http://www.retronexus.net/.well-known/acme-challenge/K-KuvzQCJWC-k_2VyJJoeSmP1HQcZE71g6giBvWSCJs:
certbot | Connection refused
certbot |
certbot | To fix these errors, please make sure that your domain …Run Code Online (Sandbox Code Playgroud) 我不是 docker 专家,我只是在习惯它。我想将主机上生成的 ssl 证书复制到我的 docker 容器中。我读到它应该能够处理volumesdocker-compose 文件中的参数,但启动我的服务器时它总是令人兴奋,因为它无法在工作目录中找到复制的文件。
文件夹结构
- repo
- backend
- api
- static
- ssl
- dockerfile
- frontend
- docker-compose.yml
Run Code Online (Sandbox Code Playgroud)
Dockerfile
FROM node:14-alpine
ENV NODE_ENV=production SERVER_PORT_HTTP=80 SERVER_PORT_HTTPS=443
WORKDIR /usr/src/app
RUN npm install
COPY . .
EXPOSE ${SERVER_PORT_HTTP} ${SERVER_PORT_HTTPS}
CMD [ "npm", "run", "start" ]
Run Code Online (Sandbox Code Playgroud)
Docker-Compose
version: "3"
services:
api:
build:
context: ./backend/api
ports:
- "80:80"
- "443:443"
volumes:
- /etc/letsencrypt/live/api.example.com:/static/ssl
restart: unless-stopped
Run Code Online (Sandbox Code Playgroud) 我将通过 certbot 为 nginx 安装 SSL
但我遇到这个错误:“DNS 问题:NXDOMAIN 正在查找www.example.com的 A - 检查该域是否存在 DNS 记录”
但是,我在 Cloudflare 中有两条 A 记录:
example.com ip
www ip
Run Code Online (Sandbox Code Playgroud)
我应该怎么办?
我知道certbot certificates给了我所有可用证书的完整列表。
我也知道certbot delete做了同样的事情,然后让我能够删除一个。
但是,考虑到 certbot 与 nginx 和 apache 集成,有没有办法让它删除当前 nginx 未使用的所有证书?
另一种方法是打开 中的所有配置/etc/nginx/site-enabled,记下所有正在使用的证书,运行certbot certificates,记下所有未使用的证书并在列表中一一找到它们certbot delete。
我正在为我的域名使用 certbot-auto 生成证书 https。我使用这样的命令
sudo ./certbot-auto
Run Code Online (Sandbox Code Playgroud)
没关系,但是当我更新证书时使用命令
sudo ./certbot-auto renew --dry-run
Run Code Online (Sandbox Code Playgroud)
它无法更新证书并显示如下错误消息:
/root/.local/share/letsencrypt/lib/python2.6/site-packages/cryptography/__init__.py:26: DeprecationWarning: Python 2.6 is no longer supported by the Python core team, please upgrade your Python. A future version of cryptography will drop support for Python 2.6
DeprecationWarning
Saving debug log to /var/log/letsencrypt/letsencrypt.log
-------------------------------------------------------------------------------
Processing /etc/letsencrypt/renewal/example.asia.conf
-------------------------------------------------------------------------------
Cert not due for renewal, but simulating renewal for dry run
Starting new HTTPS connection (1): acme-staging.api.letsencrypt.org
Renewing an existing certificate
Performing the following challenges:
tls-sni-01 challenge for example.asia
tls-sni-01 …Run Code Online (Sandbox Code Playgroud) 我成功使用certbot-nginx插件。
我知道它是开源的,托管在github上。
但是我没有足够的技能来分析此代码。
例如:
我有几个由nginx代理的内部站点。所有virtualhost配置均具有以下匿名访问限制:
allow 192.168.1.0/24;
allow 192.168.0.0/24;
allow 10.88.0.0/16;
allow 127.0.0.1;
# gate1.example.com
allow X.X.X.X;
# gate2.example.com
allow X.X.X.X;
# other gate's
# .......
deny all;
Run Code Online (Sandbox Code Playgroud)
此访问限制禁止letencrypt服务器以及所有其他未定义的主机。
但是certbot renew --nginx正常执行证书更新。
它是如何工作的 ?
是否安全?
我使用 Certbot 容器通过 Letsencrypt 生成证书:
$ mkdir /home/$USER/letsencrypt
$ docker run -it --rm -p 80:80 -p 443:443 -v /home/$USER/letsencrypt:/etc/letsencrypt certbot/certbot certonly --standalone --email user@example.com --agree-tos -d example.com
Run Code Online (Sandbox Code Playgroud)
我导航到生成的证书:
$ cd /home/$USER/letsencrypt/live/example.com
Run Code Online (Sandbox Code Playgroud)
我可以验证chain.pem:
$ openssl verify chain.pem
chain.pem: OK
Run Code Online (Sandbox Code Playgroud)
我可以看到里面有什么chain.pem:
$ openssl x509 -noout -in chain.pem -subject -issuer
subject=C = US, O = Let's Encrypt, CN = Let's Encrypt Authority X3
issuer=O = Digital Signature Trust Co., CN = DST Root CA X3
Run Code Online (Sandbox Code Playgroud)
我无法验证cert.pem(大概是因为它需要链):
$ …Run Code Online (Sandbox Code Playgroud) 感谢您的阅读!
当我docker-compose up在 laradock 上做的时候,我终于得到了一个类似 title 的错误。
在这种情况下,有人知道正确的解决方案吗?
docker-composer down再次尝试构建。当时我收到了一个类似标题的错误。在这种情况下,我应该docker pull certbot /certbot从 dockerhub运行吗?
我是docker系统的初学者。你有什么想法?
感谢您的阅读!
这是我的错误代码。
laradock mycomputer$ docker-compose up -d
Building certbot
Step 1/6 : FROM phusion/baseimage:latest
ERROR: Service 'certbot' failed to build: manifest for phusion/baseimage:latest not found: manifest unknown: manifest unknown
Run Code Online (Sandbox Code Playgroud)