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({
}
}
});