Skip to content

Commit 9ab5333

Browse files
authored
Merge pull request #1574 from jc21/develop
v2.9.12
2 parents 3b47dec + 3bd97ae commit 9ab5333

File tree

15 files changed

+160
-622
lines changed

15 files changed

+160
-622
lines changed

.version

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.9.11
1+
2.9.12

README.md

+2-18
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<p align="center">
22
<img src="https://nginxproxymanager.com/github.png">
33
<br><br>
4-
<img src="https://img.shields.io/badge/version-2.9.11-green.svg?style=for-the-badge">
4+
<img src="https://img.shields.io/badge/version-2.9.12-green.svg?style=for-the-badge">
55
<a href="https://hub.docker.com/repository/docker/jc21/nginx-proxy-manager">
66
<img src="https://img.shields.io/docker/stars/jc21/nginx-proxy-manager.svg?style=for-the-badge">
77
</a>
@@ -74,28 +74,12 @@ services:
7474
- '80:80'
7575
- '81:81'
7676
- '443:443'
77-
environment:
78-
DB_MYSQL_HOST: "db"
79-
DB_MYSQL_PORT: 3306
80-
DB_MYSQL_USER: "npm"
81-
DB_MYSQL_PASSWORD: "npm"
82-
DB_MYSQL_NAME: "npm"
8377
volumes:
8478
- ./data:/data
8579
- ./letsencrypt:/etc/letsencrypt
86-
db:
87-
image: 'jc21/mariadb-aria:latest'
88-
restart: unless-stopped
89-
environment:
90-
MYSQL_ROOT_PASSWORD: 'npm'
91-
MYSQL_DATABASE: 'npm'
92-
MYSQL_USER: 'npm'
93-
MYSQL_PASSWORD: 'npm'
94-
volumes:
95-
- ./data/mysql:/var/lib/mysql
9680
```
9781
98-
3. Bring up your stack
82+
3. Bring up your stack by running
9983
10084
```bash
10185
docker-compose up -d

backend/app.js

+6-7
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,12 @@ app.use(function (req, res, next) {
4040
}
4141

4242
res.set({
43-
'Strict-Transport-Security': 'includeSubDomains; max-age=631138519; preload',
44-
'X-XSS-Protection': '1; mode=block',
45-
'X-Content-Type-Options': 'nosniff',
46-
'X-Frame-Options': x_frame_options,
47-
'Cache-Control': 'no-cache, no-store, max-age=0, must-revalidate',
48-
Pragma: 'no-cache',
49-
Expires: 0
43+
'X-XSS-Protection': '1; mode=block',
44+
'X-Content-Type-Options': 'nosniff',
45+
'X-Frame-Options': x_frame_options,
46+
'Cache-Control': 'no-cache, no-store, max-age=0, must-revalidate',
47+
Pragma: 'no-cache',
48+
Expires: 0
5049
});
5150
next();
5251
});

backend/index.js

+69-68
Original file line numberDiff line numberDiff line change
@@ -44,84 +44,85 @@ async function appStart () {
4444

4545
async function createDbConfigFromEnvironment() {
4646
return new Promise((resolve, reject) => {
47-
const envMysqlHost = process.env.DB_MYSQL_HOST || null;
48-
const envMysqlPort = process.env.DB_MYSQL_PORT || null;
49-
const envMysqlUser = process.env.DB_MYSQL_USER || null;
50-
const envMysqlName = process.env.DB_MYSQL_NAME || null;
51-
const envSqliteFile = process.env.DB_SQLITE_FILE || null;
52-
53-
if ((envMysqlHost && envMysqlPort && envMysqlUser && envMysqlName) || envSqliteFile) {
54-
const fs = require('fs');
55-
const filename = (process.env.NODE_CONFIG_DIR || './config') + '/' + (process.env.NODE_ENV || 'default') + '.json';
56-
let configData = {};
57-
58-
try {
59-
configData = require(filename);
60-
} catch (err) {
61-
// do nothing
62-
}
47+
const envMysqlHost = process.env.DB_MYSQL_HOST || null;
48+
const envMysqlPort = process.env.DB_MYSQL_PORT || null;
49+
const envMysqlUser = process.env.DB_MYSQL_USER || null;
50+
const envMysqlName = process.env.DB_MYSQL_NAME || null;
51+
let envSqliteFile = process.env.DB_SQLITE_FILE || null;
52+
53+
const fs = require('fs');
54+
const filename = (process.env.NODE_CONFIG_DIR || './config') + '/' + (process.env.NODE_ENV || 'default') + '.json';
55+
let configData = {};
56+
57+
try {
58+
configData = require(filename);
59+
} catch (err) {
60+
// do nothing
61+
}
62+
63+
if (configData.database && configData.database.engine && !configData.database.fromEnv) {
64+
logger.info('Manual db configuration already exists, skipping config creation from environment variables');
65+
resolve();
66+
return;
67+
}
68+
69+
if ((!envMysqlHost || !envMysqlPort || !envMysqlUser || !envMysqlName) && !envSqliteFile){
70+
envSqliteFile = '/data/database.sqlite';
71+
logger.info(`No valid environment variables for database provided, using default SQLite file '${envSqliteFile}'`);
72+
}
6373

64-
if (configData.database && configData.database.engine && !configData.database.fromEnv) {
65-
logger.info('Manual db configuration already exists, skipping config creation from environment variables');
74+
if (envMysqlHost && envMysqlPort && envMysqlUser && envMysqlName) {
75+
const newConfig = {
76+
fromEnv: true,
77+
engine: 'mysql',
78+
host: envMysqlHost,
79+
port: envMysqlPort,
80+
user: envMysqlUser,
81+
password: process.env.DB_MYSQL_PASSWORD,
82+
name: envMysqlName,
83+
};
84+
85+
if (JSON.stringify(configData.database) === JSON.stringify(newConfig)) {
86+
// Config is unchanged, skip overwrite
6687
resolve();
6788
return;
6889
}
6990

70-
if (envMysqlHost && envMysqlPort && envMysqlUser && envMysqlName) {
71-
const newConfig = {
72-
fromEnv: true,
73-
engine: 'mysql',
74-
host: envMysqlHost,
75-
port: envMysqlPort,
76-
user: envMysqlUser,
77-
password: process.env.DB_MYSQL_PASSWORD,
78-
name: envMysqlName,
79-
};
80-
81-
if (JSON.stringify(configData.database) === JSON.stringify(newConfig)) {
82-
// Config is unchanged, skip overwrite
83-
resolve();
84-
return;
85-
}
86-
87-
logger.info('Generating MySQL db configuration from environment variables');
88-
configData.database = newConfig;
91+
logger.info('Generating MySQL knex configuration from environment variables');
92+
configData.database = newConfig;
8993

90-
} else {
91-
const newConfig = {
92-
fromEnv: true,
93-
engine: 'knex-native',
94-
knex: {
95-
client: 'sqlite3',
96-
connection: {
97-
filename: envSqliteFile
98-
},
99-
useNullAsDefault: true
100-
}
101-
};
102-
if (JSON.stringify(configData.database) === JSON.stringify(newConfig)) {
103-
// Config is unchanged, skip overwrite
104-
resolve();
105-
return;
94+
} else {
95+
const newConfig = {
96+
fromEnv: true,
97+
engine: 'knex-native',
98+
knex: {
99+
client: 'sqlite3',
100+
connection: {
101+
filename: envSqliteFile
102+
},
103+
useNullAsDefault: true
106104
}
107-
108-
logger.info('Generating Sqlite db configuration from environment variables');
109-
configData.database = newConfig;
105+
};
106+
if (JSON.stringify(configData.database) === JSON.stringify(newConfig)) {
107+
// Config is unchanged, skip overwrite
108+
resolve();
109+
return;
110110
}
111111

112-
// Write config
113-
fs.writeFile(filename, JSON.stringify(configData, null, 2), (err) => {
114-
if (err) {
115-
logger.error('Could not write db config to config file: ' + filename);
116-
reject(err);
117-
} else {
118-
logger.info('Wrote db configuration to config file: ' + filename);
119-
resolve();
120-
}
121-
});
122-
} else {
123-
resolve();
112+
logger.info('Generating SQLite knex configuration');
113+
configData.database = newConfig;
124114
}
115+
116+
// Write config
117+
fs.writeFile(filename, JSON.stringify(configData, null, 2), (err) => {
118+
if (err) {
119+
logger.error('Could not write db config to config file: ' + filename);
120+
reject(err);
121+
} else {
122+
logger.debug('Wrote db configuration to config file: ' + filename);
123+
resolve();
124+
}
125+
});
125126
});
126127
}
127128

backend/internal/certificate.js

+11-6
Original file line numberDiff line numberDiff line change
@@ -832,7 +832,7 @@ const internalCertificate = {
832832
requestLetsEncryptSsl: (certificate) => {
833833
logger.info('Requesting Let\'sEncrypt certificates for Cert #' + certificate.id + ': ' + certificate.domain_names.join(', '));
834834

835-
const cmd = certbotCommand + ' certonly --non-interactive ' +
835+
const cmd = certbotCommand + ' certonly ' +
836836
'--config "' + letsencryptConfig + '" ' +
837837
'--cert-name "npm-' + certificate.id + '" ' +
838838
'--agree-tos ' +
@@ -874,7 +874,8 @@ const internalCertificate = {
874874
// Whether the plugin has a --<name>-credentials argument
875875
const hasConfigArg = certificate.meta.dns_provider !== 'route53';
876876

877-
let mainCmd = certbotCommand + ' certonly --non-interactive ' +
877+
let mainCmd = certbotCommand + ' certonly ' +
878+
'--config "' + letsencryptConfig + '" ' +
878879
'--cert-name "npm-' + certificate.id + '" ' +
879880
'--agree-tos ' +
880881
'--email "' + certificate.meta.letsencrypt_email + '" ' +
@@ -969,10 +970,11 @@ const internalCertificate = {
969970
renewLetsEncryptSsl: (certificate) => {
970971
logger.info('Renewing Let\'sEncrypt certificates for Cert #' + certificate.id + ': ' + certificate.domain_names.join(', '));
971972

972-
const cmd = certbotCommand + ' renew --force-renewal --non-interactive ' +
973+
const cmd = certbotCommand + ' renew --force-renewal ' +
973974
'--config "' + letsencryptConfig + '" ' +
974975
'--cert-name "npm-' + certificate.id + '" ' +
975976
'--preferred-challenges "dns,http" ' +
977+
'--no-random-sleep-on-renew ' +
976978
'--disable-hook-validation ' +
977979
(letsencryptStaging ? '--staging' : '');
978980

@@ -998,9 +1000,11 @@ const internalCertificate = {
9981000

9991001
logger.info(`Renewing Let'sEncrypt certificates via ${dns_plugin.display_name} for Cert #${certificate.id}: ${certificate.domain_names.join(', ')}`);
10001002

1001-
let mainCmd = certbotCommand + ' renew --non-interactive ' +
1003+
let mainCmd = certbotCommand + ' renew ' +
1004+
'--config "' + letsencryptConfig + '" ' +
10021005
'--cert-name "npm-' + certificate.id + '" ' +
1003-
'--disable-hook-validation' +
1006+
'--disable-hook-validation ' +
1007+
'--no-random-sleep-on-renew ' +
10041008
(letsencryptStaging ? ' --staging' : '');
10051009

10061010
// Prepend the path to the credentials file as an environment variable
@@ -1026,7 +1030,8 @@ const internalCertificate = {
10261030
revokeLetsEncryptSsl: (certificate, throw_errors) => {
10271031
logger.info('Revoking Let\'sEncrypt certificates for Cert #' + certificate.id + ': ' + certificate.domain_names.join(', '));
10281032

1029-
const mainCmd = certbotCommand + ' revoke --non-interactive ' +
1033+
const mainCmd = certbotCommand + ' revoke ' +
1034+
'--config "' + letsencryptConfig + '" ' +
10301035
'--cert-path "/etc/letsencrypt/live/npm-' + certificate.id + '/fullchain.pem" ' +
10311036
'--delete-after-revoke ' +
10321037
(letsencryptStaging ? '--staging' : '');

backend/package.json

+1-6
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,9 @@
1111
"body-parser": "^1.19.0",
1212
"compression": "^1.7.4",
1313
"config": "^3.3.1",
14-
"diskdb": "^0.1.17",
1514
"express": "^4.17.1",
1615
"express-fileupload": "^1.1.9",
1716
"gravatar": "^1.8.0",
18-
"html-entities": "^1.2.1",
1917
"json-schema-ref-parser": "^8.0.0",
2018
"jsonwebtoken": "^8.5.1",
2119
"knex": "^0.20.13",
@@ -27,12 +25,9 @@
2725
"nodemon": "^2.0.2",
2826
"objection": "^2.2.16",
2927
"path": "^0.12.7",
30-
"pg": "^7.12.1",
31-
"restler": "^3.4.0",
3228
"signale": "^1.4.0",
3329
"sqlite3": "^4.1.1",
34-
"temp-write": "^4.0.0",
35-
"unix-timestamp": "^0.2.0"
30+
"temp-write": "^4.0.0"
3631
},
3732
"signale": {
3833
"displayDate": true,

backend/templates/_location.conf

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
location {{ path }} {
2-
set $upstream {{ forward_scheme }}://{{ forward_host }}:{{ forward_port }}{{ forward_path }}$request_uri;
2+
set $targetUri {{ forward_scheme }}://{{ forward_host }}:{{ forward_port }}{{ forward_path }};
3+
{% unless path contains "~" and path contains "(" and path contains ")" %}
4+
if ($request_uri != /){
5+
set $targetUri $targetUri$request_uri;
6+
}
7+
{% endunless %}
38
proxy_set_header Host $host;
49
proxy_set_header X-Forwarded-Scheme $scheme;
510
proxy_set_header X-Forwarded-Proto $scheme;
611
proxy_set_header X-Forwarded-For $remote_addr;
712
proxy_set_header X-Real-IP $remote_addr;
8-
proxy_pass $upstream;
13+
proxy_pass $targetUri;
914

1015
{% if access_list_id > 0 %}
1116
{% if access_list.items.length > 0 %}

0 commit comments

Comments
 (0)