mirror of
https://github.com/NginxProxyManager/nginx-proxy-manager.git
synced 2026-02-11 21:22:57 +00:00
Merge pull request #5260 from jerry-yuan/develop
All checks were successful
Close stale issues and PRs / stale (push) Successful in 36s
All checks were successful
Close stale issues and PRs / stale (push) Successful in 36s
Add trust_forwarded_proto option for SSL redirect handling in r…
This commit is contained in:
43
backend/migrations/20260131163528_trust_forwarded_proto.js
Normal file
43
backend/migrations/20260131163528_trust_forwarded_proto.js
Normal file
@@ -0,0 +1,43 @@
|
||||
import { migrate as logger } from "../logger.js";
|
||||
|
||||
const migrateName = "trust_forwarded_proto";
|
||||
|
||||
/**
|
||||
* Migrate
|
||||
*
|
||||
* @see http://knexjs.org/#Schema
|
||||
*
|
||||
* @param {Object} knex
|
||||
* @returns {Promise}
|
||||
*/
|
||||
const up = function (knex) {
|
||||
logger.info(`[${migrateName}] Migrating Up...`);
|
||||
|
||||
return knex.schema
|
||||
.alterTable('proxy_host', (table) => {
|
||||
table.tinyint('trust_forwarded_proto').notNullable().defaultTo(0);
|
||||
})
|
||||
.then(() => {
|
||||
logger.info(`[${migrateName}] proxy_host Table altered`);
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Undo Migrate
|
||||
*
|
||||
* @param {Object} knex
|
||||
* @returns {Promise}
|
||||
*/
|
||||
const down = function (knex) {
|
||||
logger.info(`[${migrateName}] Migrating Down...`);
|
||||
|
||||
return knex.schema
|
||||
.alterTable('proxy_host', (table) => {
|
||||
table.dropColumn('trust_forwarded_proto');
|
||||
})
|
||||
.then(() => {
|
||||
logger.info(`[${migrateName}] proxy_host Table altered`);
|
||||
});
|
||||
};
|
||||
|
||||
export { up, down };
|
||||
@@ -21,6 +21,7 @@ const boolFields = [
|
||||
"enabled",
|
||||
"hsts_enabled",
|
||||
"hsts_subdomains",
|
||||
"trust_forwarded_proto",
|
||||
];
|
||||
|
||||
class ProxyHost extends Model {
|
||||
|
||||
@@ -22,7 +22,8 @@
|
||||
"enabled",
|
||||
"locations",
|
||||
"hsts_enabled",
|
||||
"hsts_subdomains"
|
||||
"hsts_subdomains",
|
||||
"trust_forwarded_proto"
|
||||
],
|
||||
"properties": {
|
||||
"id": {
|
||||
@@ -141,6 +142,11 @@
|
||||
"hsts_subdomains": {
|
||||
"$ref": "../common.json#/properties/hsts_subdomains"
|
||||
},
|
||||
"trust_forwarded_proto":{
|
||||
"type": "boolean",
|
||||
"description": "Trust the forwarded headers",
|
||||
"example": false
|
||||
},
|
||||
"certificate": {
|
||||
"oneOf": [
|
||||
{
|
||||
|
||||
@@ -58,7 +58,8 @@
|
||||
"enabled": true,
|
||||
"locations": [],
|
||||
"hsts_enabled": false,
|
||||
"hsts_subdomains": false
|
||||
"hsts_subdomains": false,
|
||||
"trust_forwarded_proto": false
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -56,6 +56,7 @@
|
||||
"locations": [],
|
||||
"hsts_enabled": false,
|
||||
"hsts_subdomains": false,
|
||||
"trust_forwarded_proto": false,
|
||||
"owner": {
|
||||
"id": 1,
|
||||
"created_on": "2025-10-28T00:50:24.000Z",
|
||||
|
||||
@@ -56,6 +56,9 @@
|
||||
"hsts_subdomains": {
|
||||
"$ref": "../../../../components/proxy-host-object.json#/properties/hsts_subdomains"
|
||||
},
|
||||
"trust_forwarded_proto": {
|
||||
"$ref": "../../../../components/proxy-host-object.json#/properties/trust_forwarded_proto"
|
||||
},
|
||||
"http2_support": {
|
||||
"$ref": "../../../../components/proxy-host-object.json#/properties/http2_support"
|
||||
},
|
||||
@@ -122,6 +125,7 @@
|
||||
"locations": [],
|
||||
"hsts_enabled": false,
|
||||
"hsts_subdomains": false,
|
||||
"trust_forwarded_proto": false,
|
||||
"owner": {
|
||||
"id": 1,
|
||||
"created_on": "2025-10-28T00:50:24.000Z",
|
||||
|
||||
@@ -48,6 +48,9 @@
|
||||
"hsts_subdomains": {
|
||||
"$ref": "../../../components/proxy-host-object.json#/properties/hsts_subdomains"
|
||||
},
|
||||
"trust_forwarded_proto": {
|
||||
"$ref": "../../../components/proxy-host-object.json#/properties/trust_forwarded_proto"
|
||||
},
|
||||
"http2_support": {
|
||||
"$ref": "../../../components/proxy-host-object.json#/properties/http2_support"
|
||||
},
|
||||
@@ -119,6 +122,7 @@
|
||||
"locations": [],
|
||||
"hsts_enabled": false,
|
||||
"hsts_subdomains": false,
|
||||
"trust_forwarded_proto": false,
|
||||
"certificate": null,
|
||||
"owner": {
|
||||
"id": 1,
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
{% if certificate and certificate_id > 0 -%}
|
||||
{% if ssl_forced == 1 or ssl_forced == true %}
|
||||
# Force SSL
|
||||
{% if trust_forwarded_proto == true %}
|
||||
set $trust_forwarded_proto "T";
|
||||
{% else %}
|
||||
set $trust_forwarded_proto "F";
|
||||
{% endif %}
|
||||
include conf.d/include/force-ssl.conf;
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
Reference in New Issue
Block a user