gpt4 book ai didi

javascript - Let's encrypt auto renewal (Nginx) 错误

转载 作者:搜寻专家 更新时间:2023-10-31 22:44:30 25 4
gpt4 key购买 nike

我正在尝试设置 greenlock-express在 nginx 代理后面运行。

这是我的nginx配置

...
# redirect
server {
listen 80;
listen [::]:80;
server_name mydomain.com;

location / {
return 301 https://$server_name$request_uri;
}
}

# serve
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name mydomain.com;

# SSL settings
ssl on;
ssl_certificate C:/path/to/mydomain.com/fullchain.pem;
ssl_certificate_key C:/path/to/mydomain.com/privkey.pem;

# enable session resumption to improve https performance
ssl_session_cache shared:SSL:50m;
ssl_session_timeout 1d;
ssl_session_tickets off;

# enables server-side protection from BEAST attacks
ssl_prefer_server_ciphers on;
# disable SSLv3(enabled by default since nginx 0.8.19) since it's less secure then TLS
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

# ciphers chosen for forward secrecy and compatibility
ssl_ciphers 'ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:!DSS';

# enable OCSP stapling (mechanism by which a site can convey certificate revocation information to visitors in a privacy-preserving, scalable manner)
resolver 8.8.8.8 8.8.4.4;
ssl_stapling on;
ssl_stapling_verify on;
ssl_trusted_certificate C:/path/to/mydomain.com/chain.pem;

# config to enable HSTS(HTTP Strict Transport Security) https://developer.mozilla.org/en-US/docs/Security/HTTP_Strict_Transport_Security
add_header Strict-Transport-Security "max-age=31536000; includeSubdomains; preload";

# added to make handshake take less resources
keepalive_timeout 70;

location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_pass https://127.0.0.1:3001/;
proxy_redirect off;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
...

我有 Node 服务器在端口 3000 (http) 和端口 3001 (https) 上运行。其他一切似乎都正常,但证书不会更新并在 3 个月后过期。

如果我关闭 nginx 并在端口 80 (http) 和端口 443 (https) 上运行 Node 服务器,那么它会更新证书。

我确保 .well-known/acme-challenge 被转发到 Node 服务器,即当我转到 url http(s)://mydomain.com/.well -known/acme-challenge/randomstr 我得到以下响应:

{ 
"error": {
"message": "Error: These aren't the tokens you're looking for. Move along."
}
}

最佳答案

为 ACME 身份验证分离 webroot 的简单方法。

为 ACME 身份验证创建一个 webroot 目录。

C:\www\letsencrypt\.well-known

在nginx配置中,将ACME认证的webroot设置为之前创建的目录。

http://example.com/.well-known/acme-challenge/token -> C:/www/letsencrypt/.well-known/acme-challenge/token

server {
listen 80;
listen [::]:80;
server_name mydomain.com;

location ^~ /.well-known/acme-challenge/ {
default_type "text/plain";
root C:/www/letsencrypt;
}

location / {
return 301 https://$server_name$request_uri;
}
}

重启 nginx。

您可以在 certbot 中更改您的 webroot 以重新获得身份验证。

certbot certonly --webroot -w C:\www\letsencrypt\ -d exapmle.com --dry-run

First, test it by adding the --dry-run option. Otherwise, you may experience issues limiting the number of authentication attempts.

关于javascript - Let's encrypt auto renewal (Nginx) 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49155344/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com