mirror of
https://github.com/jc21/nginx-proxy-manager.git
synced 2024-08-30 18:22:48 +00:00
Merge pull request #883 from baruffaldi/master
Forward scheme and http code added for redirection hosts
This commit is contained in:
commit
74db0004bd
41
backend/migrations/20210210154702_redirection_scheme.js
Normal file
41
backend/migrations/20210210154702_redirection_scheme.js
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
const migrate_name = 'redirection_scheme';
|
||||||
|
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('redirection_host', (table) => {
|
||||||
|
table.string('forward_scheme').notNull().defaultTo('$scheme');
|
||||||
|
})
|
||||||
|
.then(function () {
|
||||||
|
logger.info('[' + migrate_name + '] redirection_host Table altered');
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Undo Migrate
|
||||||
|
*
|
||||||
|
* @param {Object} knex
|
||||||
|
* @param {Promise} Promise
|
||||||
|
* @returns {Promise}
|
||||||
|
*/
|
||||||
|
exports.down = function (knex/*, Promise*/) {
|
||||||
|
logger.info('[' + migrate_name + '] Migrating Down...');
|
||||||
|
|
||||||
|
return knex.schema.table('redirection_host', (table) => {
|
||||||
|
table.dropColumn('forward_scheme');
|
||||||
|
})
|
||||||
|
.then(function () {
|
||||||
|
logger.info('[' + migrate_name + '] redirection_host Table altered');
|
||||||
|
});
|
||||||
|
};
|
41
backend/migrations/20210210154703_redirection_status_code.js
Normal file
41
backend/migrations/20210210154703_redirection_status_code.js
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
const migrate_name = 'redirection_status_code';
|
||||||
|
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('redirection_host', (table) => {
|
||||||
|
table.integer('forward_http_code').notNull().unsigned().defaultTo(302);
|
||||||
|
})
|
||||||
|
.then(function () {
|
||||||
|
logger.info('[' + migrate_name + '] redirection_host Table altered');
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Undo Migrate
|
||||||
|
*
|
||||||
|
* @param {Object} knex
|
||||||
|
* @param {Promise} Promise
|
||||||
|
* @returns {Promise}
|
||||||
|
*/
|
||||||
|
exports.down = function (knex/*, Promise*/) {
|
||||||
|
logger.info('[' + migrate_name + '] Migrating Down...');
|
||||||
|
|
||||||
|
return knex.schema.table('redirection_host', (table) => {
|
||||||
|
table.dropColumn('forward_http_code');
|
||||||
|
})
|
||||||
|
.then(function () {
|
||||||
|
logger.info('[' + migrate_name + '] redirection_host Table altered');
|
||||||
|
});
|
||||||
|
};
|
@ -179,6 +179,18 @@
|
|||||||
"pattern": "^(?:\\*\\.)?(?:[^.*]+\\.?)+[^.]$"
|
"pattern": "^(?:\\*\\.)?(?:[^.*]+\\.?)+[^.]$"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"http_code": {
|
||||||
|
"description": "HTTP Status Code",
|
||||||
|
"example": 302,
|
||||||
|
"type": "integer",
|
||||||
|
"minimum": 0
|
||||||
|
},
|
||||||
|
"scheme": {
|
||||||
|
"description": "RFC Protocol",
|
||||||
|
"example": "HTTPS or $scheme",
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 4
|
||||||
|
},
|
||||||
"enabled": {
|
"enabled": {
|
||||||
"description": "Is Enabled",
|
"description": "Is Enabled",
|
||||||
"example": true,
|
"example": true,
|
||||||
|
@ -18,6 +18,12 @@
|
|||||||
"domain_names": {
|
"domain_names": {
|
||||||
"$ref": "../definitions.json#/definitions/domain_names"
|
"$ref": "../definitions.json#/definitions/domain_names"
|
||||||
},
|
},
|
||||||
|
"forward_http_code": {
|
||||||
|
"$ref": "../definitions.json#/definitions/http_code"
|
||||||
|
},
|
||||||
|
"forward_scheme": {
|
||||||
|
"$ref": "../definitions.json#/definitions/scheme"
|
||||||
|
},
|
||||||
"forward_domain_name": {
|
"forward_domain_name": {
|
||||||
"$ref": "../definitions.json#/definitions/domain_name"
|
"$ref": "../definitions.json#/definitions/domain_name"
|
||||||
},
|
},
|
||||||
@ -67,6 +73,12 @@
|
|||||||
"domain_names": {
|
"domain_names": {
|
||||||
"$ref": "#/definitions/domain_names"
|
"$ref": "#/definitions/domain_names"
|
||||||
},
|
},
|
||||||
|
"forward_http_code": {
|
||||||
|
"$ref": "#/definitions/forward_http_code"
|
||||||
|
},
|
||||||
|
"forward_scheme": {
|
||||||
|
"$ref": "#/definitions/forward_scheme"
|
||||||
|
},
|
||||||
"forward_domain_name": {
|
"forward_domain_name": {
|
||||||
"$ref": "#/definitions/forward_domain_name"
|
"$ref": "#/definitions/forward_domain_name"
|
||||||
},
|
},
|
||||||
@ -134,12 +146,20 @@
|
|||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
"required": [
|
"required": [
|
||||||
"domain_names",
|
"domain_names",
|
||||||
|
"forward_scheme",
|
||||||
|
"forward_http_code",
|
||||||
"forward_domain_name"
|
"forward_domain_name"
|
||||||
],
|
],
|
||||||
"properties": {
|
"properties": {
|
||||||
"domain_names": {
|
"domain_names": {
|
||||||
"$ref": "#/definitions/domain_names"
|
"$ref": "#/definitions/domain_names"
|
||||||
},
|
},
|
||||||
|
"forward_http_code": {
|
||||||
|
"$ref": "#/definitions/forward_http_code"
|
||||||
|
},
|
||||||
|
"forward_scheme": {
|
||||||
|
"$ref": "#/definitions/forward_scheme"
|
||||||
|
},
|
||||||
"forward_domain_name": {
|
"forward_domain_name": {
|
||||||
"$ref": "#/definitions/forward_domain_name"
|
"$ref": "#/definitions/forward_domain_name"
|
||||||
},
|
},
|
||||||
@ -195,6 +215,12 @@
|
|||||||
"domain_names": {
|
"domain_names": {
|
||||||
"$ref": "#/definitions/domain_names"
|
"$ref": "#/definitions/domain_names"
|
||||||
},
|
},
|
||||||
|
"forward_http_code": {
|
||||||
|
"$ref": "#/definitions/forward_http_code"
|
||||||
|
},
|
||||||
|
"forward_scheme": {
|
||||||
|
"$ref": "#/definitions/forward_scheme"
|
||||||
|
},
|
||||||
"forward_domain_name": {
|
"forward_domain_name": {
|
||||||
"$ref": "#/definitions/forward_domain_name"
|
"$ref": "#/definitions/forward_domain_name"
|
||||||
},
|
},
|
||||||
|
@ -18,9 +18,9 @@ server {
|
|||||||
{% include "_hsts.conf" %}
|
{% include "_hsts.conf" %}
|
||||||
|
|
||||||
{% if preserve_path == 1 or preserve_path == true %}
|
{% if preserve_path == 1 or preserve_path == true %}
|
||||||
return 301 $scheme://{{ forward_domain_name }}$request_uri;
|
return {{ forward_http_code }} {{ forward_scheme }}://{{ forward_domain_name }}$request_uri;
|
||||||
{% else %}
|
{% else %}
|
||||||
return 301 $scheme://{{ forward_domain_name }};
|
return {{ forward_http_code }} {{ forward_scheme }}://{{ forward_domain_name }};
|
||||||
{% endif %}
|
{% endif %}
|
||||||
}
|
}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -22,12 +22,35 @@
|
|||||||
<input type="text" name="domain_names" class="form-control" id="input-domains" value="<%- domain_names.join(',') %>" required>
|
<input type="text" name="domain_names" class="form-control" id="input-domains" value="<%- domain_names.join(',') %>" required>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-12 col-md-12">
|
<div class="col-sm-3 col-md-3">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-label"><%- i18n('redirection-hosts', 'forward-scheme') %><span class="form-required">*</span></label>
|
||||||
|
<select name="forward_scheme" class="form-control custom-select" placeholder="$scheme">
|
||||||
|
<option value="$scheme" <%- forward_scheme === '$scheme' ? 'selected' : '' %>>auto</option>
|
||||||
|
<option value="http" <%- forward_scheme === 'http' ? 'selected' : '' %>>http</option>
|
||||||
|
<option value="https" <%- forward_scheme === 'https' ? 'selected' : '' %>>https</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-sm-9 col-md-9">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="form-label"><%- i18n('redirection-hosts', 'forward-domain') %><span class="form-required">*</span></label>
|
<label class="form-label"><%- i18n('redirection-hosts', 'forward-domain') %><span class="form-required">*</span></label>
|
||||||
<input type="text" name="forward_domain_name" class="form-control text-monospace" placeholder="" value="<%- forward_domain_name %>" required>
|
<input type="text" name="forward_domain_name" class="form-control text-monospace" placeholder="" value="<%- forward_domain_name %>" required>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="col-sm-12 col-md-12">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-label"><%- i18n('redirection-hosts', 'forward-http-status-code') %><span class="form-required">*</span></label>
|
||||||
|
<select name="forward_http_code" class="form-control custom-select" placeholder="301">
|
||||||
|
<option value="300" <%- forward_http_code == '300' ? 'selected' : '' %>>300 Multiple choices</option>
|
||||||
|
<option value="301" <%- forward_http_code == '301' ? 'selected' : '' %>>301 Moved permanently</option>
|
||||||
|
<option value="302" <%- forward_http_code == '302' ? 'selected' : '' %>>302 Found</option>
|
||||||
|
<option value="303" <%- forward_http_code == '303' ? 'selected' : '' %>>303 See other</option>
|
||||||
|
<option value="307" <%- forward_http_code == '307' ? 'selected' : '' %>>307 Temporary redirect</option>
|
||||||
|
<option value="308" <%- forward_http_code == '308' ? 'selected' : '' %>>308 Permanent redirect</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="col-sm-6 col-md-6">
|
<div class="col-sm-6 col-md-6">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="custom-switch">
|
<label class="custom-switch">
|
||||||
|
@ -22,6 +22,12 @@
|
|||||||
<%- i18n('str', 'created-on', {date: formatDbDate(created_on, 'Do MMMM YYYY')}) %>
|
<%- i18n('str', 'created-on', {date: formatDbDate(created_on, 'Do MMMM YYYY')}) %>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
|
<td>
|
||||||
|
<div class="text-monospace"><%- forward_http_code %></div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div class="text-monospace"><%- forward_scheme == '$scheme' ? 'auto' : forward_scheme %></div>
|
||||||
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<div class="text-monospace"><%- forward_domain_name %></div>
|
<div class="text-monospace"><%- forward_domain_name %></div>
|
||||||
</td>
|
</td>
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
<thead>
|
<thead>
|
||||||
<th width="30"> </th>
|
<th width="30"> </th>
|
||||||
<th><%- i18n('str', 'source') %></th>
|
<th><%- i18n('str', 'source') %></th>
|
||||||
|
<th><%- i18n('redirection-hosts', 'forward-http-status-code') %></th>
|
||||||
|
<th><%- i18n('redirection-hosts', 'forward-scheme') %></th>
|
||||||
<th><%- i18n('str', 'destination') %></th>
|
<th><%- i18n('str', 'destination') %></th>
|
||||||
<th><%- i18n('str', 'ssl') %></th>
|
<th><%- i18n('str', 'ssl') %></th>
|
||||||
<th><%- i18n('str', 'status') %></th>
|
<th><%- i18n('str', 'status') %></th>
|
||||||
|
@ -137,6 +137,8 @@
|
|||||||
"empty": "There are no Redirection Hosts",
|
"empty": "There are no Redirection Hosts",
|
||||||
"add": "Add Redirection Host",
|
"add": "Add Redirection Host",
|
||||||
"form-title": "{id, select, undefined{New} other{Edit}} Redirection Host",
|
"form-title": "{id, select, undefined{New} other{Edit}} Redirection Host",
|
||||||
|
"forward-scheme": "Scheme",
|
||||||
|
"forward-http-status-code": "HTTP Code",
|
||||||
"forward-domain": "Forward Domain",
|
"forward-domain": "Forward Domain",
|
||||||
"preserve-path": "Preserve Path",
|
"preserve-path": "Preserve Path",
|
||||||
"delete": "Delete Proxy Host",
|
"delete": "Delete Proxy Host",
|
||||||
|
@ -9,6 +9,8 @@ const model = Backbone.Model.extend({
|
|||||||
created_on: null,
|
created_on: null,
|
||||||
modified_on: null,
|
modified_on: null,
|
||||||
domain_names: [],
|
domain_names: [],
|
||||||
|
forward_http_code: 0,
|
||||||
|
forward_scheme: null,
|
||||||
forward_domain_name: '',
|
forward_domain_name: '',
|
||||||
preserve_path: true,
|
preserve_path: true,
|
||||||
certificate_id: 0,
|
certificate_id: 0,
|
||||||
|
Loading…
Reference in New Issue
Block a user