mirror of
https://github.com/tobychui/zoraxy.git
synced 2025-08-06 13:18:30 +02:00
Fixed #255
- Added host header manual overwrite feature - Added toggle for automatic hop-by-hop header removing
This commit is contained in:
@@ -83,6 +83,41 @@
|
||||
<div class="ui divider"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ui divider"></div>
|
||||
<div class="ui basic segment" style="background-color: #f7f7f7; border-radius: 1em;">
|
||||
<div class="ui fluid accordion">
|
||||
<div class="title">
|
||||
<i class="dropdown icon" tabindex="0"><div class="menu" tabindex="-1"></div></i>
|
||||
Advance Settings
|
||||
</div>
|
||||
<div class="content">
|
||||
<br>
|
||||
<div class="ui yellow message">
|
||||
<p><i class="exclamation triangle icon"></i>Settings in this section are for advanced users. Invalid settings might cause werid, unexpected behavior.</p>
|
||||
</div>
|
||||
<div class="ui container">
|
||||
<h4>Overwrite Host Header</h4>
|
||||
<p>Manual override the automatic "Host" header rewrite logic. Leave empty for automatic.</p>
|
||||
<div class="ui fluid action input">
|
||||
<input type="text" id="manualHostOverwrite" placeholder="Overwrite Host name">
|
||||
<button onclick="updateManualHostOverwrite();" class="ui basic icon button" title="Update"><i class="ui green save icon"></i></button>
|
||||
<button onclick="clearManualHostOverwrite();" class="ui basic icon button" title="Clear"><i class="ui grey remove icon"></i></button>
|
||||
</div>
|
||||
|
||||
<div class="ui divider"></div>
|
||||
<h4>Remove Hop-by-hop Headers</h4>
|
||||
<p>Remove headers like "Connection" and "Keep-Alive" from both upstream and downstream requests. Set to ON by default.</p>
|
||||
<div class="ui toggle checkbox">
|
||||
<input type="checkbox" id="removeHopByHop" name="">
|
||||
<label>Remove Hop-by-hop Header<br>
|
||||
<small>This should be ON by default</small></label>
|
||||
</div>
|
||||
<div class="ui divider"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="ui tab basic segment" data-tab="security">
|
||||
<h4>HTTP Strict Transport Security</h4>
|
||||
@@ -129,6 +164,7 @@
|
||||
|
||||
<script>
|
||||
$('.menu .item').tab();
|
||||
$(".accordion").accordion();
|
||||
let permissionPolicyKeys = [];
|
||||
|
||||
let editingEndpoint = {};
|
||||
@@ -512,6 +548,93 @@
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
/* Manual HOST header overwrite */
|
||||
function updateManualHostOverwrite(){
|
||||
updateManualHostOverwriteVal(function(data){
|
||||
if (data.error != undefined){
|
||||
parent.msgbox(data.error, false);
|
||||
}else{
|
||||
parent.msgbox("Host field Overwrite Updated");
|
||||
initManualHostOverwriteValue();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function clearManualHostOverwrite(){
|
||||
$('#manualHostOverwrite').val('');
|
||||
updateManualHostOverwriteVal(function(data){
|
||||
if (data.error != undefined){
|
||||
parent.msgbox(data.error, false);
|
||||
}else{
|
||||
parent.msgbox("Host field Overwrite Cleared");
|
||||
initManualHostOverwriteValue();
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function updateManualHostOverwriteVal(callback=undefined){
|
||||
let newHostname = $("#manualHostOverwrite").val().trim();
|
||||
$.ajax({
|
||||
url: "/api/proxy/header/handleHostOverwrite",
|
||||
method: "POST",
|
||||
data: {
|
||||
"domain": editingEndpoint.ep,
|
||||
"hostname": newHostname,
|
||||
},
|
||||
success: function(data){
|
||||
callback(data);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function initManualHostOverwriteValue(){
|
||||
$.get("/api/proxy/header/handleHostOverwrite?domain=" + editingEndpoint.ep, function(data){
|
||||
if (data.error != undefined){
|
||||
parent.msgbox(data.error, false);
|
||||
}else{
|
||||
$("#manualHostOverwrite").val(data);
|
||||
}
|
||||
});
|
||||
}
|
||||
initManualHostOverwriteValue();
|
||||
|
||||
/* Hop-by-hop headers */
|
||||
function initHopByHopRemoverState(){
|
||||
$.get("/api/proxy/header/handleHopByHop?domain=" + editingEndpoint.ep, function(data){
|
||||
if (data.error != undefined){
|
||||
parent.msgbox(data.error);
|
||||
}else{
|
||||
if (data == true){
|
||||
$("#removeHopByHop").parent().checkbox("set checked");
|
||||
}else{
|
||||
$("#removeHopByHop").parent().checkbox("set unchecked");
|
||||
}
|
||||
|
||||
//Bind event to the checkbox
|
||||
$("#removeHopByHop").on("change", function(evt){
|
||||
let isChecked = $(this)[0].checked;
|
||||
$.ajax({
|
||||
url: "/api/proxy/header/handleHopByHop",
|
||||
method: "POST",
|
||||
data: {
|
||||
"domain": editingEndpoint.ep,
|
||||
"removeHopByHop": isChecked,
|
||||
},
|
||||
success: function(data){
|
||||
if (data.error != undefined){
|
||||
parent.msgbox(data.error, false);
|
||||
}else{
|
||||
parent.msgbox("Hop-by-Hop header rule updated");
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
initHopByHopRemoverState();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Reference in New Issue
Block a user