|
@@ -2,6 +2,7 @@
|
|
|
<html>
|
|
|
<head>
|
|
|
<!-- Notes: This should be open in its original path-->
|
|
|
+ <meta charset="utf-8">
|
|
|
<link rel="stylesheet" href="../script/semantic/semantic.min.css">
|
|
|
<script src="../script/jquery-3.6.0.min.js"></script>
|
|
|
<script src="../script/semantic/semantic.min.js"></script>
|
|
@@ -23,7 +24,7 @@
|
|
|
}
|
|
|
|
|
|
#upstreamTable{
|
|
|
- max-height: 400px;
|
|
|
+ max-height: 480px;
|
|
|
border-radius: 0.3em;
|
|
|
padding: 0.3em;
|
|
|
overflow-y: auto;
|
|
@@ -70,12 +71,12 @@
|
|
|
<i class="green add icon"></i>
|
|
|
<div class="content">
|
|
|
Add Upstream Server
|
|
|
- <div class="sub header">Create new fallback or load balance upstream</div>
|
|
|
+ <div class="sub header">Create new load balance or fallback upstream origin</div>
|
|
|
</div>
|
|
|
</h4>
|
|
|
<p style="margin-bottom: 0.4em;">Target IP address with port</p>
|
|
|
<div class="ui fluid small input">
|
|
|
- <input type="text" placeholder="" onchange="cleanProxyTargetValue(this);"><br>
|
|
|
+ <input type="text" id="originURL" onchange="cleanProxyTargetValue(this);"><br>
|
|
|
</div>
|
|
|
<small>E.g. 192.168.0.101:8000 or example.com</small>
|
|
|
<br><br>
|
|
@@ -90,12 +91,12 @@
|
|
|
<small>Check this if proxy target is using self signed certificates</small></label>
|
|
|
</div><br>
|
|
|
<div class="ui checkbox" style="margin-top: 0.4em;">
|
|
|
- <input type="checkbox" id="SkipWebSocketOriginCheck" ${upstream.SkipWebSocketOriginCheck?"checked":""}>
|
|
|
+ <input type="checkbox" id="SkipWebSocketOriginCheck" checked>
|
|
|
<label>Skip WebSocket Origin Check<br>
|
|
|
<small>Check this to allow cross-origin websocket requests</small></label>
|
|
|
</div>
|
|
|
<br><br>
|
|
|
- <button class="ui basic button"><i class="ui green circle check icon"></i> Create</button>
|
|
|
+ <button class="ui basic button" onclick="addNewUpstream();"><i class="ui green circle add icon"></i> Create</button>
|
|
|
</div>
|
|
|
<div class="ui divider"></div>
|
|
|
<div class="field" >
|
|
@@ -218,9 +219,58 @@
|
|
|
targetDomain = targetDomain.substr(8);
|
|
|
$(input).val(targetDomain);
|
|
|
$("#requireTLS").parent().checkbox("set checked");
|
|
|
+ }else{
|
|
|
+ //URL does not contains https or http protocol tag
|
|
|
+ //sniff header
|
|
|
+ $.ajax({
|
|
|
+ url: "/api/proxy/tlscheck",
|
|
|
+ data: {url: targetDomain},
|
|
|
+ success: function(data){
|
|
|
+ if (data.error != undefined){
|
|
|
+
|
|
|
+ }else if (data == "https"){
|
|
|
+ $("#requireTLS").parent().checkbox("set checked");
|
|
|
+ }else if (data == "http"){
|
|
|
+ $("#requireTLS").parent().checkbox("set unchecked");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ //Add a new upstream to this http proxy rule
|
|
|
+ function addNewUpstream(){
|
|
|
+ let origin = $("#originURL").val().trim();
|
|
|
+ let requireTLS = $("#requireTLS")[0].checked;
|
|
|
+ let skipVerification = $("#skipTlsVerification")[0].checked;
|
|
|
+ let skipWebSocketOriginCheck = $("#SkipWebSocketOriginCheck")[0].checked;
|
|
|
+
|
|
|
+ if (origin == ""){
|
|
|
+ parent.msgbox("Upstream origin cannot be empty", false);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ $.ajax({
|
|
|
+ url: "/api/proxy/upstream/add",
|
|
|
+ method: "POST",
|
|
|
+ data:{
|
|
|
+ "ep": editingEndpoint.ep,
|
|
|
+ "origin": origin,
|
|
|
+ "tls": requireTLS,
|
|
|
+ "tlsval": skipVerification,
|
|
|
+ "bpwsorg":skipWebSocketOriginCheck
|
|
|
+ },
|
|
|
+ success: function(data){
|
|
|
+ if (data.error != undefined){
|
|
|
+ parent.msgbox(data.error, false);
|
|
|
+ }else{
|
|
|
+ parent.msgbox("New upstream origin added");
|
|
|
+ initOriginList();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
if (window.location.hash.length > 1){
|
|
|
let payloadHash = window.location.hash.substr(1);
|
|
|
try{
|