Skip to content

Commit 83686c4

Browse files
committed
Added websock upgrade option for base proxy host locations
1 parent efa1424 commit 83686c4

File tree

8 files changed

+115
-20
lines changed

8 files changed

+115
-20
lines changed

bin/migrate_create

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash
2+
3+
if [ "$1" == "" ]; then
4+
echo "Error: migrate name must be specified as first arg"
5+
exit 1
6+
else
7+
# Code path
8+
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
9+
if hash realpath 2>/dev/null; then
10+
export CODEBASE=$(realpath $SCRIPT_DIR/..)
11+
elif hash grealpath 2>/dev/null; then
12+
export CODEBASE=$(grealpath $SCRIPT_DIR/..)
13+
else
14+
export CODEBASE=$(readlink -e $SCRIPT_DIR/..)
15+
fi
16+
17+
if [ -z "$CODEBASE" ]; then
18+
echo "Unable to determine absolute codebase directory"
19+
exit 1
20+
fi
21+
22+
cd "$CODEBASE"
23+
24+
sudo /usr/local/bin/docker-compose run --rm --no-deps app node node_modules/knex/bin/cli.js migrate:make "$1"
25+
exit $?
26+
fi
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
'use strict';
2+
3+
const migrate_name = 'websockets';
4+
const logger = require('../logger').migrate;
5+
6+
/**
7+
* Migrate
8+
*
9+
* @see http://knexjs.org/#Schema
10+
*
11+
* @param {Object} knex
12+
* @param {Promise} Promise
13+
* @returns {Promise}
14+
*/
15+
exports.up = function (knex/*, Promise*/) {
16+
logger.info('[' + migrate_name + '] Migrating Up...');
17+
18+
return knex.schema.table('proxy_host', function (proxy_host) {
19+
proxy_host.integer('allow_websocket_upgrade').notNull().unsigned().defaultTo(0);
20+
})
21+
.then(() => {
22+
logger.info('[' + migrate_name + '] proxy_host Table altered');
23+
});
24+
25+
};
26+
27+
/**
28+
* Undo Migrate
29+
*
30+
* @param {Object} knex
31+
* @param {Promise} Promise
32+
* @returns {Promise}
33+
*/
34+
exports.down = function (knex, Promise) {
35+
logger.warn('[' + migrate_name + '] You can\'t migrate down this one.');
36+
return Promise.resolve(true);
37+
};

src/backend/schema/endpoints/proxy-hosts.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@
3939
"caching_enabled": {
4040
"$ref": "../definitions.json#/definitions/caching_enabled"
4141
},
42+
"allow_websocket_upgrade": {
43+
"description": "Allow Websocket Upgrade for all paths",
44+
"example": true,
45+
"type": "boolean"
46+
},
4247
"access_list_id": {
4348
"$ref": "../definitions.json#/definitions/access_list_id"
4449
},
@@ -80,6 +85,9 @@
8085
"caching_enabled": {
8186
"$ref": "#/definitions/caching_enabled"
8287
},
88+
"allow_websocket_upgrade": {
89+
"$ref": "#/definitions/allow_websocket_upgrade"
90+
},
8391
"access_list_id": {
8492
"$ref": "#/definitions/access_list_id"
8593
},
@@ -148,6 +156,9 @@
148156
"caching_enabled": {
149157
"$ref": "#/definitions/caching_enabled"
150158
},
159+
"allow_websocket_upgrade": {
160+
"$ref": "#/definitions/allow_websocket_upgrade"
161+
},
151162
"access_list_id": {
152163
"$ref": "#/definitions/access_list_id"
153164
},
@@ -200,6 +211,9 @@
200211
"caching_enabled": {
201212
"$ref": "#/definitions/caching_enabled"
202213
},
214+
"allow_websocket_upgrade": {
215+
"$ref": "#/definitions/allow_websocket_upgrade"
216+
},
203217
"access_list_id": {
204218
"$ref": "#/definitions/access_list_id"
205219
},

src/backend/templates/proxy_host.conf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ server {
2222

2323
{% include "_forced_ssl.conf" %}
2424

25+
{% if allow_websocket_upgrade == 1 or allow_websocket_upgrade == true %}
26+
proxy_set_header Upgrade $http_upgrade;
27+
proxy_set_header Connection "upgrade";
28+
proxy_http_version 1.1;
29+
{% endif %}
30+
2531
# Proxy!
2632
include conf.d/include/proxy.conf;
2733
}

src/frontend/js/app/nginx/proxy/form.ejs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,15 @@
5050
</label>
5151
</div>
5252
</div>
53+
<div class="col-sm-12 col-md-12">
54+
<div class="form-group">
55+
<label class="custom-switch">
56+
<input type="checkbox" class="custom-switch-input" name="allow_websocket_upgrade" value="1"<%- allow_websocket_upgrade ? ' checked' : '' %>>
57+
<span class="custom-switch-indicator"></span>
58+
<span class="custom-switch-description"><%- i18n('proxy-hosts', 'allow-websocket-upgrade') %></span>
59+
</label>
60+
</div>
61+
</div>
5362
<div class="col-sm-12 col-md-12">
5463
<div class="form-group">
5564
<label class="form-label"><%- i18n('proxy-hosts', 'access-list') %></label>

src/frontend/js/app/nginx/proxy/form.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,10 @@ module.exports = Mn.View.extend({
5454
let data = this.ui.form.serializeJSON();
5555

5656
// Manipulate
57-
data.forward_port = parseInt(data.forward_port, 10);
58-
data.block_exploits = !!data.block_exploits;
59-
data.caching_enabled = !!data.caching_enabled;
57+
data.forward_port = parseInt(data.forward_port, 10);
58+
data.block_exploits = !!data.block_exploits;
59+
data.caching_enabled = !!data.caching_enabled;
60+
data.allow_websocket_upgrade = !!data.allow_websocket_upgrade;
6061

6162
if (typeof data.ssl_forced !== 'undefined' && data.ssl_forced === '1') {
6263
data.ssl_forced = true;

src/frontend/js/i18n/messages.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@
9898
"delete-confirm": "Are you sure you want to delete the Proxy host for: <strong>{domains}</strong>?",
9999
"help-title": "What is a Proxy Host?",
100100
"help-content": "A Proxy Host is the incoming endpoint for a web service that you want to forward.\nIt provides optional SSL termination for your service that might not have SSL support built in.\nProxy Hosts are the most common use for the Nginx Proxy Manager.",
101-
"access-list": "Access List"
101+
"access-list": "Access List",
102+
"allow-websocket-upgrade": "Allow Websocket HTTP Upgrades"
102103
},
103104
"redirection-hosts": {
104105
"title": "Redirection Hosts",

src/frontend/js/models/proxy-host.js

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,24 @@ const model = Backbone.Model.extend({
77

88
defaults: function () {
99
return {
10-
id: undefined,
11-
created_on: null,
12-
modified_on: null,
13-
domain_names: [],
14-
forward_ip: '',
15-
forward_port: null,
16-
access_list_id: 0,
17-
certificate_id: 0,
18-
ssl_forced: false,
19-
caching_enabled: false,
20-
block_exploits: false,
21-
advanced_config: '',
22-
meta: {},
10+
id: undefined,
11+
created_on: null,
12+
modified_on: null,
13+
domain_names: [],
14+
forward_ip: '',
15+
forward_port: null,
16+
access_list_id: 0,
17+
certificate_id: 0,
18+
ssl_forced: false,
19+
caching_enabled: false,
20+
allow_websocket_upgrade: false,
21+
block_exploits: false,
22+
advanced_config: '',
23+
meta: {},
2324
// The following are expansions:
24-
owner: null,
25-
access_list: null,
26-
certificate: null
25+
owner: null,
26+
access_list: null,
27+
certificate: null
2728
};
2829
}
2930
});

0 commit comments

Comments
 (0)