add PROXY to stream hosts.

This commit is contained in:
baudneo
2022-10-10 13:59:59 -06:00
parent b8978cb955
commit 5970b74321
11 changed files with 170 additions and 15 deletions

View File

@@ -42,6 +42,32 @@
</label>
</div>
</div>
<div class="col-sm-6 col-md-6">
<div class="form-group">
<label class="custom-switch">
<input type="checkbox" class="custom-switch-input" name="stream_enable_proxy_protocol" value="1"<%- stream_enable_proxy_protocol ? ' checked' : '' %>>
<span class="custom-switch-indicator"></span>
<span class="custom-switch-description"><%- i18n('streams', 'enable_proxy_protocol') %><a href="https://docs.nginx.com/nginx/admin-guide/load-balancer/using-proxy-protocol/#proxy-protocol-for-a-tcp-connection-to-an-upstream" target="_blank"><i class="fe fe-help-circle"></i></a></span>
</label>
</div>
</div>
<div class="col-sm-6 col-md-6">
<div class="form-group">
<label class="custom-switch">
<input type="checkbox" class="custom-switch-input" name="stream_allow_proxy_protocol" value="1"<%- stream_allow_proxy_protocol ? ' checked' : '' %>>
<span class="custom-switch-indicator"></span>
<span class="custom-switch-description"><%- i18n('streams', 'allow_proxy_protocol') %> <a href="https://docs.nginx.com/nginx/admin-guide/load-balancer/using-proxy-protocol/#introduction" target="_blank"><i class="fe fe-help-circle"></i></a></span>
</label>
</div>
</div>
<div class="col-sm-12 col-md-12">
<div class="form-group">
<label class="form-label"><%- i18n('streams', 'load-balancer-ip') %> <a href="https://docs.nginx.com/nginx/admin-guide/load-balancer/using-proxy-protocol/#changing-the-load-balancers-ip-address-to-the-client-ip-address" target="_blank"><i class="fe fe-help-circle"></i></a></label>
<input type="text" name="stream_load_balancer_ip" class="form-control text-monospace" placeholder="" value="<%- stream_load_balancer_ip %>" autocomplete="off" maxlength="255" <%- stream_allow_proxy_protocol ? '' : ' disabled' %>>
</div>
</div>
<div class="col-sm-12 col-md-12">
<div class="forward-type-error invalid-feedback"><%- i18n('streams', 'forward-type-error') %></div>
</div>

View File

@@ -18,13 +18,23 @@ module.exports = Mn.View.extend({
buttons: '.modal-footer button',
switches: '.custom-switch-input',
cancel: 'button.cancel',
save: 'button.save'
save: 'button.save',
stream_allow_proxy_protocol: 'input[name="stream_allow_proxy_protocol"]',
stream_enable_proxy_protocol: 'input[name="stream_enable_proxy_protocol"]',
stream_load_balancer_ip: 'input[name="stream_load_balancer_ip"]'
},
events: {
'change @ui.switches': function () {
this.ui.type_error.hide();
},
'change @ui.stream_allow_proxy_protocol': function () {
let checked = this.ui.stream_allow_proxy_protocol.prop('checked');
this.ui.stream_load_balancer_ip
.prop('disabled', !checked)
.parents('.form-group')
.css('opacity', checked ? 1 : 0.5);
},
'click @ui.save': function (e) {
e.preventDefault();
@@ -47,6 +57,8 @@ module.exports = Mn.View.extend({
data.forwarding_port = parseInt(data.forwarding_port, 10);
data.tcp_forwarding = !!data.tcp_forwarding;
data.udp_forwarding = !!data.udp_forwarding;
data.stream_enable_proxy_protocol = !!data.stream_enable_proxy_protocol;
data.stream_allow_proxy_protocol = !!data.stream_allow_proxy_protocol;
let method = App.Api.Nginx.Streams.create;
let is_new = true;
@@ -82,3 +94,4 @@ module.exports = Mn.View.extend({
}
}
});

View File

@@ -134,8 +134,8 @@
"ignore-invalid-upstream-ssl": "Ignore Invalid SSL",
"custom-forward-host-help": "Add a path for sub-folder forwarding.\nExample: 203.0.113.25/path/",
"search": "Search Host…",
"enable-proxy-protocol": "Enable PROXY Protocol",
"load-balancer-ip": "Load balancer or TCP proxy IP / CIDR range "
"enable-proxy-protocol": "Allow PROXY Protocol (Pass through)",
"load-balancer-ip": "AUTHORIZED Load balancer or TCP proxy IP / CIDR range"
},
"redirection-hosts": {
"title": "Redirection Hosts",
@@ -181,7 +181,10 @@
"delete-confirm": "Are you sure you want to delete this Stream?",
"help-title": "What is a Stream?",
"help-content": "A relatively new feature for Nginx, a Stream will serve to forward TCP/UDP traffic directly to another computer on the network.\nIf you're running game servers, FTP or SSH servers this can come in handy.",
"search": "Search Incoming Port…"
"search": "Search Incoming Port…",
"allow-proxy-protocol": "Allow PROXY Protocol (Pass through)",
"enable-proxy-protocol": "Enable PROXY Protocol (Create and override PROXY protocol instead of passing through)",
"load-balancer-ip": "AUTHORIZED Load balancer or TCP proxy IP / CIDR range"
},
"certificates": {
"title": "SSL Certificates",

View File

@@ -13,6 +13,9 @@ const model = Backbone.Model.extend({
forwarding_port: null,
tcp_forwarding: true,
udp_forwarding: false,
stream_allow_proxy_protocol: false,
stream_enable_proxy_protocol: false,
stream_load_balancer_ip: '',
enabled: true,
meta: {},
// The following are expansions: