我正在尝试设置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";
    }
}
...
我在端口 3000 (http) 和端口 3001 (https) 上运行节点服务器。其他一切似乎都在工作,但证书不会更新并在 3 个月后过期。
如果我关闭 nginx 并在端口 80 (http) 和端口 443 (https) 上运行节点服务器,那么它会更新证书。
我确保将.well-known/acme-challenge其转发到节点服务器,即当我转到 url 时,http(s)://mydomain.com/.well-known/acme-challenge/randomstr我得到以下响应:
{ 
  "error": { 
    "message": "Error: These aren't the tokens you're looking for. Move along." 
  } 
}