Skip to content

Commit 1a64d44

Browse files
authored
Merge pull request NginxProxyManager#955 from jc21/develop
v2.8.1
2 parents b7b808d + ba5f0c2 commit 1a64d44

24 files changed

+272
-52
lines changed

.version

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.8.0
1+
2.8.1

Jenkinsfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ pipeline {
222222
always {
223223
sh 'docker-compose down --rmi all --remove-orphans --volumes -t 30'
224224
sh 'echo Reverting ownership'
225-
sh 'docker run --rm -v $(pwd):/data ${DOCKER_CI_TOOLS} chown -R $(id -u):$(id -g) /data'
225+
sh 'docker run --rm -v $(pwd):/data jc21/ci-tools chown -R $(id -u):$(id -g) /data'
226226
}
227227
success {
228228
juxtapose event: 'success'

README.md

+1-1
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.8.0-green.svg?style=for-the-badge">
4+
<img src="https://img.shields.io/badge/version-2.8.1-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>

backend/internal/proxy-host.js

+4
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,10 @@ const internalProxyHost = {
189189
expand: ['owner', 'certificate', 'access_list.[clients,items]']
190190
})
191191
.then((row) => {
192+
if (!row.enabled) {
193+
// No need to add nginx config if host is disabled
194+
return row;
195+
}
192196
// Configure nginx
193197
return internalNginx.configure(proxyHostModel, 'proxy_host', row)
194198
.then((new_meta) => {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
const migrate_name = 'redirection_scheme';
2+
const logger = require('../logger').migrate;
3+
4+
/**
5+
* Migrate
6+
*
7+
* @see http://knexjs.org/#Schema
8+
*
9+
* @param {Object} knex
10+
* @param {Promise} Promise
11+
* @returns {Promise}
12+
*/
13+
exports.up = function (knex/*, Promise*/) {
14+
15+
logger.info('[' + migrate_name + '] Migrating Up...');
16+
17+
return knex.schema.table('redirection_host', (table) => {
18+
table.string('forward_scheme').notNull().defaultTo('$scheme');
19+
})
20+
.then(function () {
21+
logger.info('[' + migrate_name + '] redirection_host Table altered');
22+
});
23+
};
24+
25+
/**
26+
* Undo Migrate
27+
*
28+
* @param {Object} knex
29+
* @param {Promise} Promise
30+
* @returns {Promise}
31+
*/
32+
exports.down = function (knex/*, Promise*/) {
33+
logger.info('[' + migrate_name + '] Migrating Down...');
34+
35+
return knex.schema.table('redirection_host', (table) => {
36+
table.dropColumn('forward_scheme');
37+
})
38+
.then(function () {
39+
logger.info('[' + migrate_name + '] redirection_host Table altered');
40+
});
41+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
const migrate_name = 'redirection_status_code';
2+
const logger = require('../logger').migrate;
3+
4+
/**
5+
* Migrate
6+
*
7+
* @see http://knexjs.org/#Schema
8+
*
9+
* @param {Object} knex
10+
* @param {Promise} Promise
11+
* @returns {Promise}
12+
*/
13+
exports.up = function (knex/*, Promise*/) {
14+
15+
logger.info('[' + migrate_name + '] Migrating Up...');
16+
17+
return knex.schema.table('redirection_host', (table) => {
18+
table.integer('forward_http_code').notNull().unsigned().defaultTo(302);
19+
})
20+
.then(function () {
21+
logger.info('[' + migrate_name + '] redirection_host Table altered');
22+
});
23+
};
24+
25+
/**
26+
* Undo Migrate
27+
*
28+
* @param {Object} knex
29+
* @param {Promise} Promise
30+
* @returns {Promise}
31+
*/
32+
exports.down = function (knex/*, Promise*/) {
33+
logger.info('[' + migrate_name + '] Migrating Down...');
34+
35+
return knex.schema.table('redirection_host', (table) => {
36+
table.dropColumn('forward_http_code');
37+
})
38+
.then(function () {
39+
logger.info('[' + migrate_name + '] redirection_host Table altered');
40+
});
41+
};

backend/models/token.js

+14-3
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,23 @@
44
*/
55

66
const _ = require('lodash');
7-
const config = require('config');
87
const jwt = require('jsonwebtoken');
98
const crypto = require('crypto');
109
const error = require('../lib/error');
1110
const ALGO = 'RS256';
1211

12+
let public_key = null;
13+
let private_key = null;
14+
15+
function checkJWTKeyPair() {
16+
if (!public_key || !private_key) {
17+
let config = require('config');
18+
public_key = config.get('jwt.pub');
19+
private_key = config.get('jwt.key');
20+
}
21+
}
22+
1323
module.exports = function () {
14-
const public_key = config.get('jwt.pub');
15-
const private_key = config.get('jwt.key');
1624

1725
let token_data = {};
1826

@@ -32,6 +40,8 @@ module.exports = function () {
3240
.toString('base64')
3341
.substr(-8);
3442

43+
checkJWTKeyPair();
44+
3545
return new Promise((resolve, reject) => {
3646
jwt.sign(payload, private_key, options, (err, token) => {
3747
if (err) {
@@ -53,6 +63,7 @@ module.exports = function () {
5363
*/
5464
load: function (token) {
5565
return new Promise((resolve, reject) => {
66+
checkJWTKeyPair();
5667
try {
5768
if (!token || token === null || token === 'null') {
5869
reject(new error.AuthError('Empty token'));

backend/schema/definitions.json

+13
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,19 @@
179179
"pattern": "^(?:\\*\\.)?(?:[^.*]+\\.?)+[^.]$"
180180
}
181181
},
182+
"http_code": {
183+
"description": "Redirect HTTP Status Code",
184+
"example": 302,
185+
"type": "integer",
186+
"minimum": 300,
187+
"maximum": 308
188+
},
189+
"scheme": {
190+
"description": "RFC Protocol",
191+
"example": "HTTPS or $scheme",
192+
"type": "string",
193+
"minLength": 4
194+
},
182195
"enabled": {
183196
"description": "Is Enabled",
184197
"example": true,

backend/schema/endpoints/redirection-hosts.json

+26
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@
1818
"domain_names": {
1919
"$ref": "../definitions.json#/definitions/domain_names"
2020
},
21+
"forward_http_code": {
22+
"$ref": "../definitions.json#/definitions/http_code"
23+
},
24+
"forward_scheme": {
25+
"$ref": "../definitions.json#/definitions/scheme"
26+
},
2127
"forward_domain_name": {
2228
"$ref": "../definitions.json#/definitions/domain_name"
2329
},
@@ -67,6 +73,12 @@
6773
"domain_names": {
6874
"$ref": "#/definitions/domain_names"
6975
},
76+
"forward_http_code": {
77+
"$ref": "#/definitions/forward_http_code"
78+
},
79+
"forward_scheme": {
80+
"$ref": "#/definitions/forward_scheme"
81+
},
7082
"forward_domain_name": {
7183
"$ref": "#/definitions/forward_domain_name"
7284
},
@@ -134,12 +146,20 @@
134146
"additionalProperties": false,
135147
"required": [
136148
"domain_names",
149+
"forward_scheme",
150+
"forward_http_code",
137151
"forward_domain_name"
138152
],
139153
"properties": {
140154
"domain_names": {
141155
"$ref": "#/definitions/domain_names"
142156
},
157+
"forward_http_code": {
158+
"$ref": "#/definitions/forward_http_code"
159+
},
160+
"forward_scheme": {
161+
"$ref": "#/definitions/forward_scheme"
162+
},
143163
"forward_domain_name": {
144164
"$ref": "#/definitions/forward_domain_name"
145165
},
@@ -195,6 +215,12 @@
195215
"domain_names": {
196216
"$ref": "#/definitions/domain_names"
197217
},
218+
"forward_http_code": {
219+
"$ref": "#/definitions/forward_http_code"
220+
},
221+
"forward_scheme": {
222+
"$ref": "#/definitions/forward_scheme"
223+
},
198224
"forward_domain_name": {
199225
"$ref": "#/definitions/forward_domain_name"
200226
},

backend/setup.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,8 @@ const setupJwt = () => {
5151
reject(err);
5252
} else {
5353
logger.info('Wrote JWT key pair to config file: ' + filename);
54-
55-
logger.warn('Restarting interface to apply new configuration');
56-
process.exit(0);
54+
delete require.cache[require.resolve('config')];
55+
resolve();
5756
}
5857
});
5958
} else {

backend/templates/_hsts.conf

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{% if certificate and certificate_id > 0 -%}
22
{% if ssl_forced == 1 or ssl_forced == true %}
33
{% if hsts_enabled == 1 or hsts_enabled == true %}
4-
# HSTS (ngx_http_headers_module is required) (31536000 seconds = 1 year)
5-
add_header Strict-Transport-Security "max-age=31536000;{% if hsts_subdomains == 1 or hsts_subdomains == true -%} includeSubDomains;{% endif %} preload" always;
4+
# HSTS (ngx_http_headers_module is required) (63072000 seconds = 2 years)
5+
add_header Strict-Transport-Security "max-age=63072000;{% if hsts_subdomains == 1 or hsts_subdomains == true -%} includeSubDomains;{% endif %} preload" always;
6+
{% endif %}
67
{% endif %}
78
{% endif %}
8-
{% endif %}

backend/templates/redirection_host.conf

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ server {
1818
{% include "_hsts.conf" %}
1919

2020
{% if preserve_path == 1 or preserve_path == true %}
21-
return 301 $scheme://{{ forward_domain_name }}$request_uri;
21+
return {{ forward_http_code }} {{ forward_scheme }}://{{ forward_domain_name }}$request_uri;
2222
{% else %}
23-
return 301 $scheme://{{ forward_domain_name }};
23+
return {{ forward_http_code }} {{ forward_scheme }}://{{ forward_domain_name }};
2424
{% endif %}
2525
}
2626
{% endif %}

docs/.vuepress/config.js

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ module.exports = {
4747
["/screenshots/", "Screenshots"],
4848
["/setup/", "Setup Instructions"],
4949
["/advanced-config/", "Advanced Configuration"],
50+
["/upgrading/", "Upgrading"],
5051
["/faq/", "Frequently Asked Questions"],
5152
["/third-party/", "Third Party"]
5253
]

docs/README.md

+12
Original file line numberDiff line numberDiff line change
@@ -97,3 +97,15 @@ Password: changeme
9797
```
9898

9999
Immediately after logging in with this default user you will be asked to modify your details and change your password.
100+
101+
5. Upgrading to new versions
102+
103+
```bash
104+
docker-compose pull
105+
docker-compose up -d
106+
```
107+
108+
This project will automatically update any databases or other requirements so you don't have to follow
109+
any crazy instructions. These steps above will pull the latest updates and recreate the docker
110+
containers.
111+

docs/advanced-config/README.md

+6
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ services:
9292
volumes:
9393
- ./data:/data
9494
- ./letsencrypt:/etc/letsencrypt
95+
secrets:
96+
- MYSQL_PWD
9597
depends_on:
9698
- db
9799
db:
@@ -106,6 +108,9 @@ services:
106108
MYSQL_PASSWORD__FILE: /run/secrets/MYSQL_PWD
107109
volumes:
108110
- ./data/mysql:/var/lib/mysql
111+
secrets:
112+
- DB_ROOT_PWD
113+
- MYSQL_PWD
109114
```
110115

111116

@@ -132,6 +137,7 @@ NPM has the ability to include different custom configuration snippets in differ
132137
You can add your custom configuration snippet files at `/data/nginx/custom` as follow:
133138

134139
- `/data/nginx/custom/root.conf`: Included at the very end of nginx.conf
140+
- `/data/nginx/custom/http_top.conf`: Included at the top of the main http block
135141
- `/data/nginx/custom/http.conf`: Included at the end of the main http block
136142
- `/data/nginx/custom/stream.conf`: Included at the end of the main stream block
137143
- `/data/nginx/custom/server_proxy.conf`: Included at the end of every proxy server block

docs/upgrading/README.md

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Upgrading
2+
3+
```bash
4+
docker-compose pull
5+
docker-compose up -d
6+
```
7+
8+
This project will automatically update any databases or other requirements so you don't have to follow
9+
any crazy instructions. These steps above will pull the latest updates and recreate the docker
10+
containers.
11+

0 commit comments

Comments
 (0)