Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions backend/migrations/20260518120000_use_http_host.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { migrate as logger } from "../logger.js";

const migrateName = "use_http_host";

const up = (knex) => {
logger.info(`[${migrateName}] Migrating Up...`);
return knex.schema
.alterTable("proxy_host", (table) => {
table.tinyint("use_http_host").notNullable().defaultTo(0);
})
.then(() => {
logger.info(`[${migrateName}] proxy_host Table altered`);
});
};

const down = (knex) => {
logger.info(`[${migrateName}] Migrating Down...`);
return knex.schema
.alterTable("proxy_host", (table) => {
table.dropColumn("use_http_host");
})
.then(() => {
logger.info(`[${migrateName}] proxy_host Table altered`);
});
};

export { up, down };
1 change: 1 addition & 0 deletions backend/models/proxy_host.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const boolFields = [
"hsts_enabled",
"hsts_subdomains",
"trust_forwarded_proto",
"use_http_host",
];

class ProxyHost extends Model {
Expand Down
8 changes: 7 additions & 1 deletion backend/schema/components/proxy-host-object.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
"locations",
"hsts_enabled",
"hsts_subdomains",
"trust_forwarded_proto"
"trust_forwarded_proto",
"use_http_host"
],
"properties": {
"id": {
Expand Down Expand Up @@ -147,6 +148,11 @@
"description": "Trust the forwarded headers",
"example": false
},
"use_http_host": {
"type": "boolean",
"description": "Use $http_host (preserves port) instead of $host for the Host and X-Forwarded-Host headers",
"example": false
},
"certificate": {
"oneOf": [
{
Expand Down
3 changes: 2 additions & 1 deletion backend/schema/paths/nginx/proxy-hosts/get.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@
"locations": [],
"hsts_enabled": false,
"hsts_subdomains": false,
"trust_forwarded_proto": false
"trust_forwarded_proto": false,
"use_http_host": false
}
]
}
Expand Down
1 change: 1 addition & 0 deletions backend/schema/paths/nginx/proxy-hosts/hostID/get.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
"hsts_enabled": false,
"hsts_subdomains": false,
"trust_forwarded_proto": false,
"use_http_host": false,
"owner": {
"id": 1,
"created_on": "2025-10-28T00:50:24.000Z",
Expand Down
4 changes: 4 additions & 0 deletions backend/schema/paths/nginx/proxy-hosts/hostID/put.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@
"trust_forwarded_proto": {
"$ref": "../../../../components/proxy-host-object.json#/properties/trust_forwarded_proto"
},
"use_http_host": {
"$ref": "../../../../components/proxy-host-object.json#/properties/use_http_host"
},
"http2_support": {
"$ref": "../../../../components/proxy-host-object.json#/properties/http2_support"
},
Expand Down Expand Up @@ -126,6 +129,7 @@
"hsts_enabled": false,
"hsts_subdomains": false,
"trust_forwarded_proto": false,
"use_http_host": false,
"owner": {
"id": 1,
"created_on": "2025-10-28T00:50:24.000Z",
Expand Down
4 changes: 4 additions & 0 deletions backend/schema/paths/nginx/proxy-hosts/post.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@
"trust_forwarded_proto": {
"$ref": "../../../components/proxy-host-object.json#/properties/trust_forwarded_proto"
},
"use_http_host": {
"$ref": "../../../components/proxy-host-object.json#/properties/use_http_host"
},
"http2_support": {
"$ref": "../../../components/proxy-host-object.json#/properties/http2_support"
},
Expand Down Expand Up @@ -123,6 +126,7 @@
"hsts_enabled": false,
"hsts_subdomains": false,
"trust_forwarded_proto": false,
"use_http_host": false,
"certificate": null,
"owner": {
"id": 1,
Expand Down
7 changes: 6 additions & 1 deletion backend/templates/_location.conf
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
location {{ path }} {
{{ advanced_config }}

proxy_set_header Host $host;
{% if use_http_host == 1 or use_http_host == true %}
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Host $http_host;
{% else %}
proxy_set_header Host $host;
{% endif %}
proxy_set_header X-Forwarded-Scheme $scheme;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $remote_addr;
Expand Down
1 change: 1 addition & 0 deletions frontend/src/api/backend/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ export interface ProxyHost {
hstsEnabled: boolean;
hstsSubdomains: boolean;
trustForwardedProto: boolean;
useHttpHost: boolean;
// Expansions:
owner?: User;
accessList?: AccessList;
Expand Down
1 change: 1 addition & 0 deletions frontend/src/hooks/useProxyHost.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const fetchProxyHost = (id: number | "new") => {
hstsEnabled: false,
hstsSubdomains: false,
trustForwardedProto: false,
useHttpHost: false,
} as ProxyHost);
}
return getProxyHost(id, ["owner"]);
Expand Down
Loading