diff --git a/backend/internal/nginx.js b/backend/internal/nginx.js index 83d2c3f0..fe84607f 100644 --- a/backend/internal/nginx.js +++ b/backend/internal/nginx.js @@ -216,6 +216,11 @@ const internalNginx = { } } + // For redirection hosts, if the scheme is not http or https, set it to $scheme + if (nice_host_type === "redirection_host" && ['http', 'https'].indexOf(host.forward_scheme.toLowerCase()) === -1) { + host.forward_scheme = "$scheme"; + } + if (host.locations) { //logger.info ('host.locations = ' + JSON.stringify(host.locations, null, 2)); origLocations = [].concat(host.locations); diff --git a/backend/migrations/20251111090000_redirect_auto_scheme.js b/backend/migrations/20251111090000_redirect_auto_scheme.js new file mode 100644 index 00000000..9f5f9d06 --- /dev/null +++ b/backend/migrations/20251111090000_redirect_auto_scheme.js @@ -0,0 +1,50 @@ +import { migrate as logger } from "../logger.js"; + +const migrateName = "redirect_auto_scheme"; + +/** + * Migrate + * + * @see http://knexjs.org/#Schema + * + * @param {Object} knex + * @returns {Promise} + */ +const up = (knex) => { + logger.info(`[${migrateName}] Migrating Up...`); + + return knex.schema + .table("redirection_host", async (table) => { + // change the column default from $scheme to auto + await table.string("forward_scheme").notNull().defaultTo("auto").alter(); + await knex('redirection_host') + .where('forward_scheme', '$scheme') + .update({ forward_scheme: 'auto' }); + }) + .then(() => { + logger.info(`[${migrateName}] redirection_host Table altered`); + }); +}; + +/** + * Undo Migrate + * + * @param {Object} knex + * @returns {Promise} + */ +const down = (knex) => { + logger.info(`[${migrateName}] Migrating Down...`); + + return knex.schema + .table("redirection_host", async (table) => { + await table.string("forward_scheme").notNull().defaultTo("$scheme").alter(); + await knex('redirection_host') + .where('forward_scheme', 'auto') + .update({ forward_scheme: '$scheme' }); + }) + .then(() => { + logger.info(`[${migrateName}] redirection_host Table altered`); + }); +}; + +export { up, down }; diff --git a/frontend/src/modals/RedirectionHostModal.tsx b/frontend/src/modals/RedirectionHostModal.tsx index d2a40b56..be2fc869 100644 --- a/frontend/src/modals/RedirectionHostModal.tsx +++ b/frontend/src/modals/RedirectionHostModal.tsx @@ -162,7 +162,7 @@ const RedirectionHostModal = EasyModal.create(({ id, visible, remove }: Props) = required {...field} > - +