mirror of
https://github.com/NginxProxyManager/nginx-proxy-manager.git
synced 2025-04-28 10:02:29 +00:00
Merge d007b5c8a4c7287753cc640e2ccfd4f1d68ad1fd into 63d06da8a8591e7a9b2a1873eb91ce1c42b2b0f9
This commit is contained in:
commit
61aac3b422
42
backend/migrations/20240629165112_stream_load_balance.js
Normal file
42
backend/migrations/20240629165112_stream_load_balance.js
Normal file
@ -0,0 +1,42 @@
|
||||
const migrate_name = 'stream_load_balance';
|
||||
const logger = require('../logger').migrate;
|
||||
|
||||
/**
|
||||
* Migrate
|
||||
*
|
||||
* @see http://knexjs.org/#Schema
|
||||
*
|
||||
* @param {Object} knex
|
||||
* @param {Promise} Promise
|
||||
* @returns {Promise}
|
||||
*/
|
||||
exports.up = function (knex) {
|
||||
logger.info('[' + migrate_name + '] Migrating Up...');
|
||||
|
||||
return knex.schema
|
||||
.table('stream', (table) => {
|
||||
table.renameColumn('forwarding_host', 'forwarding_hosts');
|
||||
})
|
||||
.then(function () {
|
||||
logger.info('[' + migrate_name + '] stream Table altered');
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Undo Migrate
|
||||
*
|
||||
* @param {Object} knex
|
||||
* @param {Promise} Promise
|
||||
* @returns {Promise}
|
||||
*/
|
||||
exports.down = function (knex) {
|
||||
logger.info('[' + migrate_name + '] Migrating Down...');
|
||||
|
||||
return knex.schema
|
||||
.table('stream', (table) => {
|
||||
table.renameColumn('forwarding_hosts', 'forwarding_host');
|
||||
})
|
||||
.then(function () {
|
||||
logger.info('[' + migrate_name + '] stream Table altered');
|
||||
});
|
||||
};
|
@ -9,33 +9,43 @@ const now = require('./now_helper');
|
||||
Model.knex(db);
|
||||
|
||||
class Stream extends Model {
|
||||
$beforeInsert () {
|
||||
$beforeInsert() {
|
||||
this.created_on = now();
|
||||
this.modified_on = now();
|
||||
|
||||
// Default for forwarding_hosts
|
||||
if (typeof this.forwarding_hosts === 'undefined') {
|
||||
this.forwarding_hosts = [];
|
||||
}
|
||||
|
||||
// Default for meta
|
||||
if (typeof this.meta === 'undefined') {
|
||||
this.meta = {};
|
||||
}
|
||||
}
|
||||
|
||||
$beforeUpdate () {
|
||||
$beforeUpdate() {
|
||||
this.modified_on = now();
|
||||
|
||||
// Sort domain_names
|
||||
if (typeof this.forwarding_hosts !== 'undefined') {
|
||||
this.forwarding_hosts.sort();
|
||||
}
|
||||
}
|
||||
|
||||
static get name () {
|
||||
static get name() {
|
||||
return 'Stream';
|
||||
}
|
||||
|
||||
static get tableName () {
|
||||
static get tableName() {
|
||||
return 'stream';
|
||||
}
|
||||
|
||||
static get jsonAttributes () {
|
||||
return ['meta'];
|
||||
static get jsonAttributes() {
|
||||
return ['forwarding_hosts', 'meta'];
|
||||
}
|
||||
|
||||
static get relationMappings () {
|
||||
static get relationMappings() {
|
||||
return {
|
||||
owner: {
|
||||
relation: Model.HasOneRelation,
|
||||
|
@ -20,7 +20,7 @@
|
||||
"minimum": 1,
|
||||
"maximum": 65535
|
||||
},
|
||||
"forwarding_host": {
|
||||
"host": {
|
||||
"anyOf": [
|
||||
{
|
||||
"$ref": "../definitions.json#/definitions/domain_name"
|
||||
@ -35,6 +35,22 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"forwarding_hosts": {
|
||||
"anyOf": [
|
||||
{
|
||||
"$ref": "#/definitions/host"
|
||||
},
|
||||
{
|
||||
"type": "array",
|
||||
"minItems": 1,
|
||||
"maxItems": 15,
|
||||
"uniqueItems": true,
|
||||
"items": {
|
||||
"$ref": "#/definitions/host"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"forwarding_port": {
|
||||
"type": "integer",
|
||||
"minimum": 1,
|
||||
@ -66,8 +82,8 @@
|
||||
"incoming_port": {
|
||||
"$ref": "#/definitions/incoming_port"
|
||||
},
|
||||
"forwarding_host": {
|
||||
"$ref": "#/definitions/forwarding_host"
|
||||
"forwarding_hosts": {
|
||||
"$ref": "#/definitions/forwarding_hosts"
|
||||
},
|
||||
"forwarding_port": {
|
||||
"$ref": "#/definitions/forwarding_port"
|
||||
@ -118,15 +134,15 @@
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"incoming_port",
|
||||
"forwarding_host",
|
||||
"forwarding_hosts",
|
||||
"forwarding_port"
|
||||
],
|
||||
"properties": {
|
||||
"incoming_port": {
|
||||
"$ref": "#/definitions/incoming_port"
|
||||
},
|
||||
"forwarding_host": {
|
||||
"$ref": "#/definitions/forwarding_host"
|
||||
"forwarding_hosts": {
|
||||
"$ref": "#/definitions/forwarding_hosts"
|
||||
},
|
||||
"forwarding_port": {
|
||||
"$ref": "#/definitions/forwarding_port"
|
||||
@ -165,8 +181,8 @@
|
||||
"incoming_port": {
|
||||
"$ref": "#/definitions/incoming_port"
|
||||
},
|
||||
"forwarding_host": {
|
||||
"$ref": "#/definitions/forwarding_host"
|
||||
"forwarding_hosts": {
|
||||
"$ref": "#/definitions/forwarding_hosts"
|
||||
},
|
||||
"forwarding_port": {
|
||||
"$ref": "#/definitions/forwarding_port"
|
||||
|
@ -3,6 +3,21 @@
|
||||
# ------------------------------------------------------------
|
||||
|
||||
{% if enabled %}
|
||||
|
||||
upstream stream_{{ incoming_port }}_tcp {
|
||||
{% if forwarding_hosts.length > 1 -%}
|
||||
least_conn;
|
||||
{%- endif -%}
|
||||
|
||||
{% for forwarding_host in forwarding_hosts %}
|
||||
{% if forloop.first == true and forloop.last == true -%}
|
||||
server {{ forwarding_host }}:{{ forwarding_port }};
|
||||
{%- else -%}
|
||||
server {{ forwarding_host}}:{{ forwarding_port}} max_fails=3;
|
||||
{%- endif %}
|
||||
{%- endfor %}
|
||||
}
|
||||
|
||||
{% if tcp_forwarding == 1 or tcp_forwarding == true -%}
|
||||
server {
|
||||
listen {{ incoming_port }};
|
||||
@ -12,7 +27,7 @@ server {
|
||||
#listen [::]:{{ incoming_port }};
|
||||
{% endif %}
|
||||
|
||||
proxy_pass {{ forwarding_host }}:{{ forwarding_port }};
|
||||
proxy_pass stream_{{ incoming_port }}_tcp;
|
||||
|
||||
# Custom
|
||||
include /data/nginx/custom/server_stream[.]conf;
|
||||
@ -20,14 +35,22 @@ server {
|
||||
}
|
||||
{% endif %}
|
||||
{% if udp_forwarding == 1 or udp_forwarding == true %}
|
||||
|
||||
upstream stream_{{ incoming_port }}_udp {
|
||||
{% for forwarding_host in forwarding_hosts %}
|
||||
server {{ forwarding_host }}:{{ forwarding_port }};
|
||||
{%- endfor %}
|
||||
}
|
||||
|
||||
server {
|
||||
listen {{ incoming_port }} udp;
|
||||
{% if ipv6 -%}
|
||||
listen [::]:{{ incoming_port }} udp;
|
||||
{% else -%}
|
||||
#listen [::]:{{ incoming_port }} udp;
|
||||
#listen [::]:{{ incoming_port }} udp;
|
||||
{% endif %}
|
||||
proxy_pass {{ forwarding_host }}:{{ forwarding_port }};
|
||||
|
||||
proxy_pass stream_{{ incoming_port }}_udp;
|
||||
|
||||
# Custom
|
||||
include /data/nginx/custom/server_stream[.]conf;
|
||||
|
@ -14,8 +14,8 @@
|
||||
</div>
|
||||
<div class="col-sm-8 col-md-8">
|
||||
<div class="form-group">
|
||||
<label class="form-label"><%- i18n('streams', 'forwarding-host') %><span class="form-required">*</span></label>
|
||||
<input type="text" name="forwarding_host" class="form-control text-monospace" placeholder="example.com or 10.0.0.1 or 2001:db8:3333:4444:5555:6666:7777:8888" value="<%- forwarding_host %>" autocomplete="off" maxlength="255" required>
|
||||
<label class="form-label"><%- i18n('streams', 'forwarding-hosts') %><span class="form-required">*</span></label>
|
||||
<input type="text" name="forwarding_hosts" class="form-control text-monospace" placeholder="10.0.0.1 or 2001:db8:3333:4444:5555:6666:7777:8888" id="input-forwarding-hosts" value="<%- forwarding_hosts.join(',') %>" autocomplete="off" maxlength="255" required>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-4 col-md-4">
|
||||
|
@ -6,6 +6,8 @@ const template = require('./form.ejs');
|
||||
require('jquery-serializejson');
|
||||
require('jquery-mask-plugin');
|
||||
require('selectize');
|
||||
const Helpers = require("../../../lib/helpers");
|
||||
const certListItemTemplate = require("../certificates-list-item.ejs");
|
||||
|
||||
module.exports = Mn.View.extend({
|
||||
template: template,
|
||||
@ -13,7 +15,7 @@ module.exports = Mn.View.extend({
|
||||
|
||||
ui: {
|
||||
form: 'form',
|
||||
forwarding_host: 'input[name="forwarding_host"]',
|
||||
forwarding_hosts: 'input[name="forwarding_hosts"]',
|
||||
type_error: '.forward-type-error',
|
||||
buttons: '.modal-footer button',
|
||||
switches: '.custom-switch-input',
|
||||
@ -48,6 +50,10 @@ module.exports = Mn.View.extend({
|
||||
data.tcp_forwarding = !!data.tcp_forwarding;
|
||||
data.udp_forwarding = !!data.udp_forwarding;
|
||||
|
||||
if (typeof data.forwarding_hosts === 'string' && data.forwarding_hosts) {
|
||||
data.forwarding_hosts = data.forwarding_hosts.split(',');
|
||||
}
|
||||
|
||||
let method = App.Api.Nginx.Streams.create;
|
||||
let is_new = true;
|
||||
|
||||
@ -76,6 +82,24 @@ module.exports = Mn.View.extend({
|
||||
}
|
||||
},
|
||||
|
||||
onRender: function () {
|
||||
let view = this;
|
||||
|
||||
// Domain names
|
||||
this.ui.forwarding_hosts.selectize({
|
||||
delimiter: ',',
|
||||
persist: false,
|
||||
maxOptions: 15,
|
||||
create: function (input) {
|
||||
return {
|
||||
value: input,
|
||||
text: input
|
||||
};
|
||||
},
|
||||
createFilter: /^(?:\*\.)?(?:[^.*]+\.?)+[^.]$/
|
||||
});
|
||||
},
|
||||
|
||||
initialize: function (options) {
|
||||
if (typeof options.model === 'undefined' || !options.model) {
|
||||
this.model = new StreamModel.Model();
|
||||
|
@ -12,7 +12,11 @@
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="text-monospace"><%- forwarding_host %>:<%- forwarding_port %></div>
|
||||
<div class="text-monospace">
|
||||
<% forwarding_hosts.map(function(host) {
|
||||
%><span class="tag host-link hover-green" rel="http://<%- host %>:<%- forwarding_port %>"><%- host %>:<%- forwarding_port %></span><%
|
||||
}); %>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div>
|
||||
|
@ -3,6 +3,7 @@
|
||||
<th><%- i18n('streams', 'incoming-port') %></th>
|
||||
<th><%- i18n('str', 'destination') %></th>
|
||||
<th><%- i18n('streams', 'protocol') %></th>
|
||||
<th><%- i18n('streams', 'forwarding-port') %></th>
|
||||
<th><%- i18n('str', 'status') %></th>
|
||||
<% if (canManage) { %>
|
||||
<th> </th>
|
||||
|
@ -167,7 +167,7 @@
|
||||
"add": "Add Stream",
|
||||
"form-title": "{id, select, undefined{New} other{Edit}} Stream",
|
||||
"incoming-port": "Incoming Port",
|
||||
"forwarding-host": "Forward Host",
|
||||
"forwarding-hosts": "Forward Hoss",
|
||||
"forwarding-port": "Forward Port",
|
||||
"tcp-forwarding": "TCP Forwarding",
|
||||
"udp-forwarding": "UDP Forwarding",
|
||||
|
@ -9,7 +9,7 @@ const model = Backbone.Model.extend({
|
||||
created_on: null,
|
||||
modified_on: null,
|
||||
incoming_port: null,
|
||||
forwarding_host: null,
|
||||
forwarding_hosts: [],
|
||||
forwarding_port: null,
|
||||
tcp_forwarding: true,
|
||||
udp_forwarding: false,
|
||||
|
Loading…
x
Reference in New Issue
Block a user