From 6df7b72e08a0443b50e51e47e850724f73edbebf Mon Sep 17 00:00:00 2001 From: baruffaldi Date: Tue, 9 Feb 2021 11:23:15 +0100 Subject: [PATCH] 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) --- .version | 2 +- .../schema/endpoints/redirection-hosts.json | 26 +++++++++++++++++++ backend/templates/redirection_host.conf | 4 +-- frontend/js/app/nginx/redirection/form.ejs | 25 +++++++++++++++++- .../js/app/nginx/redirection/list/item.ejs | 6 +++++ frontend/js/models/redirection-host.js | 2 ++ 6 files changed, 61 insertions(+), 4 deletions(-) diff --git a/.version b/.version index 834f2629..dbe59006 100644 --- a/.version +++ b/.version @@ -1 +1 @@ -2.8.0 +2.8.1 diff --git a/backend/schema/endpoints/redirection-hosts.json b/backend/schema/endpoints/redirection-hosts.json index 1295fa4f..14a46998 100644 --- a/backend/schema/endpoints/redirection-hosts.json +++ b/backend/schema/endpoints/redirection-hosts.json @@ -18,6 +18,12 @@ "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": { "$ref": "../definitions.json#/definitions/domain_name" }, @@ -67,6 +73,12 @@ "domain_names": { "$ref": "#/definitions/domain_names" }, + "forward_http_code": { + "$ref": "#/definitions/forward_http_code" + }, + "forward_scheme": { + "$ref": "#/definitions/forward_scheme" + }, "forward_domain_name": { "$ref": "#/definitions/forward_domain_name" }, @@ -134,12 +146,20 @@ "additionalProperties": false, "required": [ "domain_names", + "forward_scheme", + "forward_http_code", "forward_domain_name" ], "properties": { "domain_names": { "$ref": "#/definitions/domain_names" }, + "forward_http_code": { + "$ref": "#/definitions/forward_http_code" + }, + "forward_scheme": { + "$ref": "#/definitions/forward_scheme" + }, "forward_domain_name": { "$ref": "#/definitions/forward_domain_name" }, @@ -195,6 +215,12 @@ "domain_names": { "$ref": "#/definitions/domain_names" }, + "forward_http_code": { + "$ref": "#/definitions/forward_http_code" + }, + "forward_scheme": { + "$ref": "#/definitions/forward_scheme" + }, "forward_domain_name": { "$ref": "#/definitions/forward_domain_name" }, diff --git a/backend/templates/redirection_host.conf b/backend/templates/redirection_host.conf index 463f3a8e..55e7280f 100644 --- a/backend/templates/redirection_host.conf +++ b/backend/templates/redirection_host.conf @@ -18,9 +18,9 @@ server { {% include "_hsts.conf" %} {% 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 %} - return 301 $scheme://{{ forward_domain_name }}; + return {{ forward_http_code }} {{ forward_scheme }}://{{ forward_domain_name }}; {% endif %} } {% endif %} diff --git a/frontend/js/app/nginx/redirection/form.ejs b/frontend/js/app/nginx/redirection/form.ejs index 3247233a..9e1628a5 100644 --- a/frontend/js/app/nginx/redirection/form.ejs +++ b/frontend/js/app/nginx/redirection/form.ejs @@ -22,12 +22,35 @@ -
+
+
+ + +
+
+
+
+
+ + +
+
+ +
<%- forward_http_code %>
+ + +
<%- forward_scheme %>
+
<%- forward_domain_name %>
diff --git a/frontend/js/models/redirection-host.js b/frontend/js/models/redirection-host.js index a4f11e21..1d0b0de2 100644 --- a/frontend/js/models/redirection-host.js +++ b/frontend/js/models/redirection-host.js @@ -9,6 +9,8 @@ const model = Backbone.Model.extend({ created_on: null, modified_on: null, domain_names: [], + forward_http_code: 0, + forward_scheme: null, forward_domain_name: '', preserve_path: true, certificate_id: 0,