mirror of
https://github.com/NginxProxyManager/nginx-proxy-manager.git
synced 2025-08-03 07:53:39 +00:00
dep updates/enable ssl_dyn_rec_enable/fix nginx in background/remove tempwrite
Signed-off-by: Zoey <zoey@z0ey.de>
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
const _ = require('lodash');
|
||||
const fs = require('fs');
|
||||
const https = require('https');
|
||||
const tempWrite = require('temp-write');
|
||||
const moment = require('moment');
|
||||
const logger = require('../logger').ssl;
|
||||
const error = require('../lib/error');
|
||||
@@ -11,6 +10,7 @@ const dnsPlugins = require('../certbot-dns-plugins');
|
||||
const internalAuditLog = require('./audit-log');
|
||||
const internalNginx = require('./nginx');
|
||||
const archiver = require('archiver');
|
||||
const crypto = require('crypto');
|
||||
const path = require('path');
|
||||
const { isArray } = require('lodash');
|
||||
|
||||
@@ -29,7 +29,7 @@ const internalCertificate = {
|
||||
intervalProcessing: false,
|
||||
|
||||
initTimer: () => {
|
||||
logger.info('Certbot Encrypt Renewal Timer initialized');
|
||||
logger.info('Certbot Renewal Timer initialized');
|
||||
internalCertificate.interval = setInterval(internalCertificate.processExpiringHosts, internalCertificate.intervalTimeout);
|
||||
// And do this now as well
|
||||
internalCertificate.processExpiringHosts();
|
||||
@@ -637,8 +637,10 @@ const internalCertificate = {
|
||||
* @param {String} private_key This is the entire key contents as a string
|
||||
*/
|
||||
checkPrivateKey: (private_key) => {
|
||||
return tempWrite(private_key, '/tmp')
|
||||
.then((filepath) => {
|
||||
const randomName = crypto.randomBytes(8).toString('hex');
|
||||
const filepath = path.join('/tmp', 'certificate_' + randomName);
|
||||
return fs.writeFileSync(filepath, private_key)
|
||||
.then(() => {
|
||||
return new Promise((resolve, reject) => {
|
||||
const failTimeout = setTimeout(() => {
|
||||
reject(new error.ValidationError('Result Validation Error: Validation timed out. This could be due to the key being passphrase-protected.'));
|
||||
@@ -670,8 +672,10 @@ const internalCertificate = {
|
||||
* @param {Boolean} [throw_expired] Throw when the certificate is out of date
|
||||
*/
|
||||
getCertificateInfo: (certificate, throw_expired) => {
|
||||
return tempWrite(certificate, '/tmp')
|
||||
.then((filepath) => {
|
||||
const randomName = crypto.randomBytes(8).toString('hex');
|
||||
const filepath = path.join('/root', 'certificate_' + randomName);
|
||||
return fs.writeFileSync(filepath, certificate)
|
||||
.then(() => {
|
||||
return internalCertificate.getCertificateInfoFromFile(filepath, throw_expired)
|
||||
.then((certData) => {
|
||||
fs.unlinkSync(filepath);
|
||||
|
@@ -5,6 +5,8 @@ const config = require('../lib/config');
|
||||
const utils = require('../lib/utils');
|
||||
const error = require('../lib/error');
|
||||
|
||||
const NgxPidFilePath = '/usr/local/nginx/logs/nginx.pid';
|
||||
|
||||
const internalNginx = {
|
||||
|
||||
/**
|
||||
@@ -111,11 +113,21 @@ const internalNginx = {
|
||||
/**
|
||||
* @returns {Promise}
|
||||
*/
|
||||
|
||||
reload: () => {
|
||||
return internalNginx.test()
|
||||
.then(() => {
|
||||
logger.info('Restarting Nginx');
|
||||
return utils.exec('kill $(cat /usr/local/nginx/logs/nginx.pid); nginx');
|
||||
if (fs.existsSync(NgxPidFilePath)) {
|
||||
const ngxPID = fs.readFileSync(NgxPidFilePath, 'utf8').trim();
|
||||
if (ngxPID.length > 0) {
|
||||
logger.info('Killing Nginx');
|
||||
utils.exec(`kill ${ngxPID}`);
|
||||
}
|
||||
}
|
||||
logger.info('Starting Nginx in three seconds');
|
||||
setTimeout(() => {
|
||||
utils.execfg('nginx');
|
||||
}, 3000);
|
||||
});
|
||||
},
|
||||
|
||||
@@ -159,10 +171,10 @@ const internalNginx = {
|
||||
{certificate: host.certificate}, host.locations[i]);
|
||||
|
||||
if (locationCopy.forward_host.indexOf('/') > -1) {
|
||||
const splitted = locationCopy.forward_host.split('/');
|
||||
const split = locationCopy.forward_host.split('/');
|
||||
|
||||
locationCopy.forward_host = splitted.shift();
|
||||
locationCopy.forward_path = `/${splitted.join('/')}`;
|
||||
locationCopy.forward_host = split.shift();
|
||||
locationCopy.forward_path = `/${split.join('/')}`;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line
|
||||
|
@@ -96,7 +96,7 @@ const generateKeys = () => {
|
||||
try {
|
||||
fs.writeFileSync(keysFile, JSON.stringify(keys, null, 2));
|
||||
} catch (err) {
|
||||
logger.error('Could not write JWT key pair to config file: ' + keysFile + ': ' . err.message);
|
||||
logger.error('Could not write JWT key pair to config file: ' + keysFile + ': ' + err.message);
|
||||
process.exit(1);
|
||||
}
|
||||
logger.info('Wrote JWT key pair to config file: ' + keysFile);
|
||||
@@ -150,7 +150,7 @@ module.exports = {
|
||||
},
|
||||
|
||||
/**
|
||||
* Are we running in debug mdoe?
|
||||
* Are we running in debug mode?
|
||||
*
|
||||
* @returns {boolean}
|
||||
*/
|
||||
|
@@ -1,5 +1,6 @@
|
||||
const _ = require('lodash');
|
||||
const exec = require('child_process').exec;
|
||||
const spawn = require('child_process').spawn;
|
||||
const execFile = require('child_process').execFile;
|
||||
const { Liquid } = require('liquidjs');
|
||||
const logger = require('../logger').global;
|
||||
@@ -22,6 +23,33 @@ module.exports = {
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {String} cmd
|
||||
* @returns {Promise}
|
||||
*/
|
||||
execfg: function (cmd) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const childProcess = spawn(cmd, {
|
||||
shell: true,
|
||||
detached: true,
|
||||
stdio: 'inherit' // Use the same stdio as the current process
|
||||
});
|
||||
|
||||
childProcess.on('error', (err) => {
|
||||
reject(err);
|
||||
});
|
||||
|
||||
childProcess.on('close', (code) => {
|
||||
if (code !== 0) {
|
||||
reject(new Error(`Command '${cmd}' exited with code ${code}`));
|
||||
} else {
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* @param {String} cmd
|
||||
* @param {Array} args
|
||||
|
@@ -14,23 +14,25 @@
|
||||
"express": "4.18.2",
|
||||
"express-fileupload": "1.4.0",
|
||||
"gravatar": "1.8.2",
|
||||
"jsonwebtoken": "9.0.0",
|
||||
"jsonwebtoken": "9.0.1",
|
||||
"knex": "2.4.2",
|
||||
"liquidjs": "10.8.2",
|
||||
"liquidjs": "10.8.4",
|
||||
"lodash": "4.17.21",
|
||||
"moment": "2.29.4",
|
||||
"mysql": "2.18.1",
|
||||
"node-rsa": "1.1.1",
|
||||
"objection": "3.0.1",
|
||||
"objection": "3.0.4",
|
||||
"path": "0.12.7",
|
||||
"signale": "1.4.0",
|
||||
"sqlite3": "5.1.6",
|
||||
"temp-write": "4.0.0"
|
||||
"sqlite3": "5.1.6"
|
||||
},
|
||||
"resolutions": {
|
||||
"semver": "7.5.4"
|
||||
},
|
||||
"author": "Jamie Curnow <jc@jc21.com>",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"eslint": "8.42.0",
|
||||
"eslint": "8.44.0",
|
||||
"eslint-plugin-align-assignments": "1.1.2"
|
||||
}
|
||||
}
|
||||
|
@@ -88,7 +88,7 @@
|
||||
"links": [
|
||||
{
|
||||
"title": "List",
|
||||
"description": "Returns a list of Steams",
|
||||
"description": "Returns a list of Streams",
|
||||
"href": "/nginx/streams",
|
||||
"access": "private",
|
||||
"method": "GET",
|
||||
|
Reference in New Issue
Block a user