Forward scheme and http code added for redirection hosts

You can now configure the forward_scheme and forward_http_code on user interface (section redirection hosts)
This commit is contained in:
baruffaldi 2021-02-09 11:23:15 +01:00
parent ea28da90b2
commit 6df7b72e08
6 changed files with 61 additions and 4 deletions

View File

@ -1 +1 @@
2.8.0 2.8.1

View File

@ -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"
}, },

View File

@ -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 %}

View File

@ -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-4 col-md-4">
<div class="form-group">
<label class="form-label"><%- i18n('redirection-hosts', '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-8 col-md-8">
<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', '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">

View File

@ -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 %></div>
</td>
<td> <td>
<div class="text-monospace"><%- forward_domain_name %></div> <div class="text-monospace"><%- forward_domain_name %></div>
</td> </td>

View File

@ -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,