mirror of
https://github.com/xiaoxinpro/nginx-proxy-manager-zh.git
synced 2025-01-22 21:08:13 -05:00
Trying something to fix the auto ssl renewal process
This commit is contained in:
parent
b38e239fa2
commit
b324110c49
@ -26,7 +26,7 @@ const internalSsl = {
|
|||||||
processExpiringHosts: () => {
|
processExpiringHosts: () => {
|
||||||
if (!internalSsl.interval_processing) {
|
if (!internalSsl.interval_processing) {
|
||||||
logger.info('Renewing SSL certs close to expiry...');
|
logger.info('Renewing SSL certs close to expiry...');
|
||||||
return utils.exec('/usr/bin/letsencrypt renew')
|
return utils.exec('/usr/bin/certbot renew --webroot=/config/letsencrypt-acme-challenge')
|
||||||
.then(result => {
|
.then(result => {
|
||||||
logger.info(result);
|
logger.info(result);
|
||||||
internalSsl.interval_processing = false;
|
internalSsl.interval_processing = false;
|
||||||
@ -55,7 +55,7 @@ const internalSsl = {
|
|||||||
requestSsl: host => {
|
requestSsl: host => {
|
||||||
logger.info('Requesting SSL certificates for ' + host.hostname);
|
logger.info('Requesting SSL certificates for ' + host.hostname);
|
||||||
|
|
||||||
return utils.exec('/usr/bin/letsencrypt certonly --agree-tos --email "' + host.letsencrypt_email + '" -n -a webroot --webroot-path=' + host.root_path + ' -d "' + host.hostname + '"')
|
return utils.exec('/usr/bin/letsencrypt certonly --agree-tos --email "' + host.letsencrypt_email + '" -n -a webroot --webroot-path=/config/letsencrypt-acme-challenge -d "' + host.hostname + '"')
|
||||||
.then(result => {
|
.then(result => {
|
||||||
logger.info(result);
|
logger.info(result);
|
||||||
return result;
|
return result;
|
||||||
@ -69,7 +69,7 @@ const internalSsl = {
|
|||||||
renewSsl: host => {
|
renewSsl: host => {
|
||||||
logger.info('Renewing SSL certificates for ' + host.hostname);
|
logger.info('Renewing SSL certificates for ' + host.hostname);
|
||||||
|
|
||||||
return utils.exec('/usr/bin/letsencrypt renew --force-renewal --disable-hook-validation --cert-name "' + host.hostname + '"')
|
return utils.exec('/usr/bin/certbot renew --force-renewal --disable-hook-validation --webroot-path=/config/letsencrypt-acme-challenge --cert-name "' + host.hostname + '"')
|
||||||
.then(result => {
|
.then(result => {
|
||||||
logger.info(result);
|
logger.info(result);
|
||||||
return result;
|
return result;
|
||||||
@ -83,7 +83,7 @@ const internalSsl = {
|
|||||||
deleteCerts: host => {
|
deleteCerts: host => {
|
||||||
logger.info('Deleting SSL certificates for ' + host.hostname);
|
logger.info('Deleting SSL certificates for ' + host.hostname);
|
||||||
|
|
||||||
return utils.exec('/usr/bin/letsencrypt delete -n --cert-name "' + host.hostname + '"')
|
return utils.exec('/usr/bin/certbot delete -n --cert-name "' + host.hostname + '"')
|
||||||
.then(result => {
|
.then(result => {
|
||||||
logger.info(result);
|
logger.info(result);
|
||||||
})
|
})
|
||||||
@ -101,20 +101,17 @@ const internalSsl = {
|
|||||||
let filename = internalNginx.getConfigName(host);
|
let filename = internalNginx.getConfigName(host);
|
||||||
let template_data = host;
|
let template_data = host;
|
||||||
|
|
||||||
template_data.root_path = '/tmp/' + host.hostname;
|
return new Promise((resolve, reject) => {
|
||||||
|
try {
|
||||||
|
template = fs.readFileSync(__dirname + '/../templates/letsencrypt.conf.ejs', {encoding: 'utf8'});
|
||||||
|
let config_text = ejs.render(template, template_data);
|
||||||
|
fs.writeFileSync(filename, config_text, {encoding: 'utf8'});
|
||||||
|
|
||||||
return utils.exec('mkdir -p ' + template_data.root_path)
|
resolve(template_data);
|
||||||
.then(() => {
|
} catch (err) {
|
||||||
try {
|
reject(new error.ConfigurationError(err.message));
|
||||||
template = fs.readFileSync(__dirname + '/../templates/letsencrypt.conf.ejs', {encoding: 'utf8'});
|
}
|
||||||
let config_text = ejs.render(template, template_data);
|
});
|
||||||
fs.writeFileSync(filename, config_text, {encoding: 'utf8'});
|
|
||||||
|
|
||||||
return template_data;
|
|
||||||
} catch (err) {
|
|
||||||
throw new error.ConfigurationError(err.message);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -6,6 +6,6 @@ server {
|
|||||||
access_log /config/logs/letsencrypt.log proxy;
|
access_log /config/logs/letsencrypt.log proxy;
|
||||||
|
|
||||||
location / {
|
location / {
|
||||||
root <%- root_path %>;
|
root /config/letsencrypt-acme-challenge;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@ server {
|
|||||||
<%- typeof block_exploits !== 'undefined' && block_exploits ? 'include conf.d/include/block-exploits.conf;' : '' %>
|
<%- typeof block_exploits !== 'undefined' && block_exploits ? 'include conf.d/include/block-exploits.conf;' : '' %>
|
||||||
|
|
||||||
<% if (typeof ssl !== 'undefined' && ssl) { -%>
|
<% if (typeof ssl !== 'undefined' && ssl) { -%>
|
||||||
|
include conf.d/include/letsencrypt-acme-challenge.conf;
|
||||||
include conf.d/include/ssl-ciphers.conf;
|
include conf.d/include/ssl-ciphers.conf;
|
||||||
ssl_certificate /etc/letsencrypt/live/<%- hostname %>/fullchain.pem;
|
ssl_certificate /etc/letsencrypt/live/<%- hostname %>/fullchain.pem;
|
||||||
ssl_certificate_key /etc/letsencrypt/live/<%- hostname %>/privkey.pem;
|
ssl_certificate_key /etc/letsencrypt/live/<%- hostname %>/privkey.pem;
|
||||||
|
@ -0,0 +1,25 @@
|
|||||||
|
# Rule for legitimate ACME Challenge requests (like /.well-known/acme-challenge/xxxxxxxxx)
|
||||||
|
# We use ^~ here, so that we don't check other regexes (for speed-up). We actually MUST cancel
|
||||||
|
# other regex checks, because in our other config files have regex rule that denies access to files with dotted names.
|
||||||
|
location ^~ /.well-known/acme-challenge/ {
|
||||||
|
|
||||||
|
# Set correct content type. According to this:
|
||||||
|
# https://community.letsencrypt.org/t/using-the-webroot-domain-verification-method/1445/29
|
||||||
|
# Current specification requires "text/plain" or no content header at all.
|
||||||
|
# It seems that "text/plain" is a safe option.
|
||||||
|
default_type "text/plain";
|
||||||
|
|
||||||
|
# This directory must be the same as in /etc/letsencrypt/cli.ini
|
||||||
|
# as "webroot-path" parameter. Also don't forget to set "authenticator" parameter
|
||||||
|
# there to "webroot".
|
||||||
|
# Do NOT use alias, use root! Target directory is located here:
|
||||||
|
# /var/www/common/letsencrypt/.well-known/acme-challenge/
|
||||||
|
root /config/letsencrypt-acme-challenge;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Hide /acme-challenge subdirectory and return 404 on all requests.
|
||||||
|
# It is somewhat more secure than letting Nginx return 403.
|
||||||
|
# Ending slash is important!
|
||||||
|
location = /.well-known/acme-challenge/ {
|
||||||
|
return 404;
|
||||||
|
}
|
@ -1,4 +1,6 @@
|
|||||||
#!/usr/bin/with-contenv bash
|
#!/usr/bin/with-contenv bash
|
||||||
|
|
||||||
|
mkdir -p /config/letsencrypt-acme-challenge
|
||||||
|
|
||||||
cd /srv/manager
|
cd /srv/manager
|
||||||
node --abort_on_uncaught_exception --max_old_space_size=250 /srv/manager/src/backend/index.js
|
node --abort_on_uncaught_exception --max_old_space_size=250 /srv/manager/src/backend/index.js
|
||||||
|
4
rootfs/root/.config/letsencrypt/cli.ini
Normal file
4
rootfs/root/.config/letsencrypt/cli.ini
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
text = True
|
||||||
|
non-interactive = True
|
||||||
|
authenticator = webroot
|
||||||
|
webroot-path = /config/letsencrypt-acme-challenge
|
Loading…
Reference in New Issue
Block a user