diff --git a/backend/migrations/20260425014442_proxy_protocol_stream.js b/backend/migrations/20260425014442_proxy_protocol_stream.js new file mode 100644 index 00000000..5099211b --- /dev/null +++ b/backend/migrations/20260425014442_proxy_protocol_stream.js @@ -0,0 +1,40 @@ +const migrate_name = "proxy_protocol_stream"; +import { migrate as logger } from "../logger.js"; + +/** + * Migrate + * + * @see http://knexjs.org/#Schema + * + * @param {Object} knex + * @returns {Promise} + */ +const up = (knex) => { + logger.info(`[${migrate_name}] Migrating Up...`); + + return knex.schema.table("stream", (table) => { + table.integer("enable_proxy_protocol").notNull().unsigned().defaultTo(0); + }).then(() => { + logger.info(`[${migrate_name}] stream Table altered`); + }); + +}; + +/** + * Undo Migrate + * + * @param {Object} knex + * @returns {Promise} + */ +const down = (_knex) => { + logger.info(`[${migrateName}] Migrating Down...`); + + return knex.schema.table("stream", (table) => { + table.dropColumn("enable_proxy_protocol"); + }) + .then(() => { + logger.info(`[${migrateName}] stream Table altered`); + }); +}; + +export { up, down }; diff --git a/backend/schema/components/stream-object.json b/backend/schema/components/stream-object.json index 602073ce..42a26339 100644 --- a/backend/schema/components/stream-object.json +++ b/backend/schema/components/stream-object.json @@ -12,7 +12,8 @@ "tcp_forwarding", "udp_forwarding", "enabled", - "meta" + "meta", + "enable_proxy_protocol" ], "additionalProperties": false, "properties": { @@ -70,6 +71,11 @@ "enabled": { "$ref": "../common.json#/properties/enabled" }, + "enable_proxy_protocol": { + "description": "Enable PROXY Protocol support", + "type": "boolean", + "example": false + }, "certificate_id": { "$ref": "../common.json#/properties/certificate_id" }, diff --git a/backend/schema/paths/nginx/streams/get.json b/backend/schema/paths/nginx/streams/get.json index 6dda8e34..8243f9a9 100644 --- a/backend/schema/paths/nginx/streams/get.json +++ b/backend/schema/paths/nginx/streams/get.json @@ -41,6 +41,7 @@ "nginx_err": null }, "enabled": true, + "enable_proxy_protocol": false, "certificate_id": 0 } ] diff --git a/backend/schema/paths/nginx/streams/post.json b/backend/schema/paths/nginx/streams/post.json index 0c986de8..06d5ad69 100644 --- a/backend/schema/paths/nginx/streams/post.json +++ b/backend/schema/paths/nginx/streams/post.json @@ -41,6 +41,9 @@ "certificate_id": { "$ref": "../../../components/stream-object.json#/properties/certificate_id" }, + "enable_proxy_protocol": { + "$ref": "../../../components/stream-object.json#/properties/enable_proxy_protocol", + }, "meta": { "$ref": "../../../components/stream-object.json#/properties/meta" }, @@ -56,6 +59,7 @@ "tcp_forwarding": true, "udp_forwarding": false, "certificate_id": 0, + "enable_proxy_protocol": false, "meta": {} } } @@ -83,6 +87,7 @@ "nginx_err": null }, "enabled": true, + "enable_proxy_protocol": false, "owner": { "id": 1, "created_on": "2024-10-09T02:33:16.000Z", diff --git a/backend/schema/paths/nginx/streams/streamID/get.json b/backend/schema/paths/nginx/streams/streamID/get.json index 22fae887..c2094f98 100644 --- a/backend/schema/paths/nginx/streams/streamID/get.json +++ b/backend/schema/paths/nginx/streams/streamID/get.json @@ -42,6 +42,7 @@ "nginx_err": null }, "enabled": true, + "enableProxyProtocol": false, "certificate_id": 0 } } diff --git a/backend/schema/paths/nginx/streams/streamID/put.json b/backend/schema/paths/nginx/streams/streamID/put.json index 21ae71ef..cc52fe10 100644 --- a/backend/schema/paths/nginx/streams/streamID/put.json +++ b/backend/schema/paths/nginx/streams/streamID/put.json @@ -48,6 +48,9 @@ "certificate_id": { "$ref": "../../../../components/stream-object.json#/properties/certificate_id" }, + "enable_proxy_protocol": { + "$ref": "../../../../components/stream-object.json#/properties/enable_proxy_protocol", + }, "meta": { "$ref": "../../../../components/stream-object.json#/properties/meta" } @@ -78,6 +81,7 @@ "nginx_err": null }, "enabled": true, + "enable_proxy_protocol": false, "owner": { "id": 1, "created_on": "2024-10-09T02:33:16.000Z", diff --git a/backend/templates/stream.conf b/backend/templates/stream.conf index 3a10387b..d8af054e 100644 --- a/backend/templates/stream.conf +++ b/backend/templates/stream.conf @@ -5,8 +5,9 @@ {% if enabled %} {% if tcp_forwarding == 1 or tcp_forwarding == true -%} server { - listen {{ incoming_port }} {%- if certificate %} ssl {%- endif %}; - {% unless ipv6 -%} # {%- endunless -%} listen [::]:{{ incoming_port }} {%- if certificate %} ssl {%- endif %}; + listen {{ incoming_port }} {%- if certificate %} ssl {%- endif %} {%- if enable_proxy_protocol == 1 %} proxy_protocol {%- endif %}; + # {{ enable_proxy_protocol }} + {% unless ipv6 -%} # {%- endunless -%} listen [::]:{{ incoming_port }} {%- if certificate %} ssl {%- endif %} {%- if enable_proxy_protocol == 1 %} proxy_protocol {%- endif %}; {%- include "_certificates_stream.conf" %} diff --git a/frontend/src/api/backend/models.ts b/frontend/src/api/backend/models.ts index d102b755..832b7d45 100644 --- a/frontend/src/api/backend/models.ts +++ b/frontend/src/api/backend/models.ts @@ -191,6 +191,7 @@ export interface Stream { udpForwarding: boolean; meta: Record; enabled: boolean; + enableProxyProtocol: boolean; certificateId: number; // Expansions: owner?: User; diff --git a/frontend/src/hooks/useStream.ts b/frontend/src/hooks/useStream.ts index dfdddc1a..ca8b0d57 100644 --- a/frontend/src/hooks/useStream.ts +++ b/frontend/src/hooks/useStream.ts @@ -12,6 +12,7 @@ const fetchStream = (id: number | "new") => { udpForwarding: false, meta: {}, enabled: true, + enableProxyProtocol: false, certificateId: 0, } as Stream); } diff --git a/frontend/src/modals/StreamModal.tsx b/frontend/src/modals/StreamModal.tsx index 6d553488..29cd1e21 100644 --- a/frontend/src/modals/StreamModal.tsx +++ b/frontend/src/modals/StreamModal.tsx @@ -63,6 +63,7 @@ const StreamModal = EasyModal.create(({ id, visible, remove }: Props) => { tcpForwarding: data?.tcpForwarding, udpForwarding: data?.udpForwarding, certificateId: data?.certificateId, + enableProxyProtocol: data?.enableProxyProtocol, meta: data?.meta || {}, } as any } @@ -278,6 +279,35 @@ const StreamModal = EasyModal.create(({ id, visible, remove }: Props) => { +
+ +