Skip to content

#65 custom config of ___location / on proxy host pane #75

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions src/backend/migrations/20190219223711_root_config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
'use strict';

const migrate_name = 'rootpath_config';
const logger = require('../logger').migrate;

/**
* Migrate
*
* @see http://knexjs.org/#Schema
*
* @param {Object} knex
* @param {Promise} Promise
* @returns {Promise}
*/
exports.up = function (knex/*, Promise*/) {
logger.info('[' + migrate_name + '] Migrating Up...');

return knex.schema.table('proxy_host', function (proxy_host) {
proxy_host.text('advanced_rootconfig').notNull().defaultTo('');
proxy_host.integer('enabled_rootconfig').notNull().unsigned().defaultTo(0);
})
.then(() => {
logger.info('[' + migrate_name + '] proxy_host Table altered');
});
};

/**
* Undo Migrate
*
* @param {Object} knex
* @param {Promise} Promise
* @returns {Promise}
*/
exports.down = function (knex, Promise) {
logger.warn('[' + migrate_name + '] You can\'t migrate down this one.');
return Promise.resolve(true);
};
24 changes: 24 additions & 0 deletions src/backend/schema/endpoints/proxy-hosts.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@
},
"meta": {
"type": "object"
},
"advanced_rootconfig": {
"type": "string"
},
"enabled_rootconfig": {
"type": "boolean"
}
},
"properties": {
Expand Down Expand Up @@ -128,6 +134,12 @@
},
"meta": {
"$ref": "#/definitions/meta"
},
"advanced_rootconfig": {
"$ref": "#/definitions/advanced_rootconfig"
},
"enabled_rootconfig": {
"$ref": "#/definitions/enabled_rootconfig"
}
},
"links": [
Expand Down Expand Up @@ -215,6 +227,12 @@
},
"meta": {
"$ref": "#/definitions/meta"
},
"advanced_rootconfig": {
"$ref": "#/definitions/advanced_rootconfig"
},
"enabled_rootconfig": {
"$ref": "#/definitions/enabled_rootconfig"
}
}
},
Expand Down Expand Up @@ -285,6 +303,12 @@
},
"meta": {
"$ref": "#/definitions/meta"
},
"advanced_rootconfig": {
"$ref": "#/definitions/advanced_rootconfig"
},
"enabled_rootconfig": {
"$ref": "#/definitions/enabled_rootconfig"
}
}
},
Expand Down
2 changes: 2 additions & 0 deletions src/backend/templates/proxy_host.conf
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ server {

# Proxy!
include conf.d/include/proxy.conf;

{{advanced_rootconfig}}
}
}
{% endif %}
18 changes: 16 additions & 2 deletions src/frontend/js/app/nginx/proxy/form.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
</label>
</div>
</div>
<div class="col-sm-12 col-md-12">
<div class="col-sm-6 col-md-6">
<div class="form-group">
<label class="custom-switch">
<input type="checkbox" class="custom-switch-input" name="allow_websocket_upgrade" value="1"<%- allow_websocket_upgrade ? ' checked' : '' %>>
Expand All @@ -68,7 +68,21 @@
</label>
</div>
</div>

<div class="col-sm-6 col-md-6">
<div class="form-group">
<label class="custom-switch">
<input type="checkbox" class="custom-switch-input" name="enabled_rootconfig" value="1"<%- enabled_rootconfig ? ' checked' : '' %>>
<span class="custom-switch-indicator"></span>
<span class="custom-switch-description"><%- i18n('proxy-hosts', 'advanced-config-root') %></span>
</label>
</div>
</div>
<div class="col-sm-12">
<div class="form-group">
<label class="form-label"><%- i18n('proxy-hosts', 'advanced-config-root') %></label>
<textarea name="advanced_rootconfig" rows="8" class="form-control text-monospace" placeholder="# <%- i18n('all-hosts', 'advanced-warning') %>"><%- advanced_rootconfig %></textarea>
</div>
</div>
<div class="col-sm-12 col-md-12">
<div class="form-group">
<label class="form-label"><%- i18n('proxy-hosts', 'access-list') %></label>
Expand Down
11 changes: 11 additions & 0 deletions src/frontend/js/app/nginx/proxy/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,21 @@ module.exports = Mn.View.extend({
ssl_forced: 'input[name="ssl_forced"]',
hsts_enabled: 'input[name="hsts_enabled"]',
hsts_subdomains: 'input[name="hsts_subdomains"]',
enable_rootpath: 'input[name="enabled_rootconfig"]',
config_rootpath: 'textarea[name="advanced_rootconfig"]',
http2_support: 'input[name="http2_support"]',
forward_scheme: 'select[name="forward_scheme"]',
letsencrypt: '.letsencrypt'
},

events: {
'change @ui.enable_rootpath': function(e) {
if (e.target.checked) {
this.ui.config_rootpath.parent().show();
} else {
this.ui.config_rootpath.parent().hide();
}
},
'change @ui.certificate_select': function () {
let id = this.ui.certificate_select.val();
if (id === 'new') {
Expand Down Expand Up @@ -102,6 +111,7 @@ module.exports = Mn.View.extend({
data.hsts_enabled = !!data.hsts_enabled;
data.hsts_subdomains = !!data.hsts_subdomains;
data.ssl_forced = !!data.ssl_forced;
data.enabled_rootconfig = !!data.enabled_rootconfig;

if (typeof data.domain_names === 'string' && data.domain_names) {
data.domain_names = data.domain_names.split(',');
Expand Down Expand Up @@ -162,6 +172,7 @@ module.exports = Mn.View.extend({

onRender: function () {
let view = this;
this.ui.enable_rootpath.trigger('change');

this.ui.ssl_forced.trigger('change');
this.ui.hsts_enabled.trigger('change');
Expand Down
3 changes: 2 additions & 1 deletion src/frontend/js/i18n/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@
"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.",
"access-list": "Access List",
"allow-websocket-upgrade": "Websockets Support",
"ignore-invalid-upstream-ssl": "Ignore Invalid SSL"
"ignore-invalid-upstream-ssl": "Ignore Invalid SSL",
"advanced-config-root": "Custom config of /"
},
"redirection-hosts": {
"title": "Redirection Hosts",
Expand Down
2 changes: 2 additions & 0 deletions src/frontend/js/models/proxy-host.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ const model = Backbone.Model.extend({
advanced_config: '',
enabled: true,
meta: {},
enabled_rootconfig: false,
advanced_rootconfig: null,
// The following are expansions:
owner: null,
access_list: null,
Expand Down