|
@@ -1,54 +1,65 @@
|
|
<div class="standardContainer">
|
|
<div class="standardContainer">
|
|
<div class="ui basic segment">
|
|
<div class="ui basic segment">
|
|
<h2>Default Site</h2>
|
|
<h2>Default Site</h2>
|
|
- <p>What to show when Zoraxy is hit with an unknown Host</p>
|
|
|
|
-
|
|
|
|
|
|
+ <p>Default routing options for inbound traffic (previously called Proxy Root)</p>
|
|
<div class="ui form">
|
|
<div class="ui form">
|
|
- <div class="field">
|
|
|
|
- <div class="ui checkbox">
|
|
|
|
- <input type="checkbox" id="useStaticWebServer" onchange="handleUseStaticWebServerAsRoot()">
|
|
|
|
- <label>Internal Static Web Server <br><small>Check this if you prefer a more Apache / Nginx like experience</small></label>
|
|
|
|
|
|
+ <div class="grouped fields">
|
|
|
|
+ <label>What to show when Zoraxy is hit with an unknown Host?</label>
|
|
|
|
+ <div class="field">
|
|
|
|
+ <div class="ui radio defaultsite checkbox">
|
|
|
|
+ <input type="radio" name="defaultsiteOption" checked="checked" value="webserver">
|
|
|
|
+ <label>Internal Static Web Server<br>
|
|
|
|
+ <small>Check this if you prefer a more Apache / Nginx like experience</small>
|
|
|
|
+ </label>
|
|
|
|
+ </div>
|
|
</div>
|
|
</div>
|
|
- </div>
|
|
|
|
- <div class="ui horizontal divider">OR</div>
|
|
|
|
- <div class="field">
|
|
|
|
- <label>Reverse Proxy Target</label>
|
|
|
|
- <input type="text" id="proxyRoot" onchange="checkRootRequireTLS(this.value);">
|
|
|
|
- <small>E.g. localhost:8080</small>
|
|
|
|
- </div>
|
|
|
|
- <div class="field">
|
|
|
|
- <div class="ui checkbox">
|
|
|
|
- <input type="checkbox" id="rootReqTLS">
|
|
|
|
- <label>Reverse proxy target require TLS connection <br><small>Check this if your proxy root URL starts with https://</small></label>
|
|
|
|
|
|
+ <div class="field">
|
|
|
|
+ <div class="ui radio defaultsite checkbox">
|
|
|
|
+ <input type="radio" name="defaultsiteOption" value="proxy">
|
|
|
|
+ <label>Reverse Proxy Target<br>
|
|
|
|
+ <small>Proxy the request to a target IP / domain</small>
|
|
|
|
+ </label>
|
|
|
|
+ </div>
|
|
</div>
|
|
</div>
|
|
- </div>
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- <br>
|
|
|
|
- <button class="ui basic button" onclick="setProxyRoot()"><i class="teal home icon" ></i> Update Proxy Root</button>
|
|
|
|
- <div class="ui divider"></div>
|
|
|
|
- <div class="field">
|
|
|
|
- <h4>Root Routing Options</h4>
|
|
|
|
- </div>
|
|
|
|
- <div class="field">
|
|
|
|
- <div class="ui checkbox">
|
|
|
|
- <input type="checkbox" id="unsetRedirect">
|
|
|
|
- <label>Enable redirect for unset subdomains <br><small>Redirect subdomain that is not found to custom domain</small></label>
|
|
|
|
|
|
+ <div class="field">
|
|
|
|
+ <div class="ui radio defaultsite checkbox">
|
|
|
|
+ <input type="radio" name="defaultsiteOption" value="redirect">
|
|
|
|
+ <label>Redirect<br>
|
|
|
|
+ <small>Redirect the user to a new location</small>
|
|
|
|
+ </label>
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
|
|
+ <div class="field">
|
|
|
|
+ <div class="ui radio defaultsite checkbox">
|
|
|
|
+ <input type="radio" name="defaultsiteOption" value="notfound">
|
|
|
|
+ <label>Show 404 NOT FOUND<br>
|
|
|
|
+ <small>Respond to request with a 404 page</small>
|
|
|
|
+ </label>
|
|
|
|
+ </div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
- <div class="ui basic segment" id="unsetRedirectDomainWrapper" style="background-color: #f7f7f7; border-radius: 1em; margin-left: 2em; padding-left: 2em; display:none;">
|
|
|
|
- <div style="
|
|
|
|
- position: absolute;
|
|
|
|
- top:0;
|
|
|
|
- left: 1em;
|
|
|
|
- width: 0px;
|
|
|
|
- height: 0px;
|
|
|
|
- margin-top: -10px;
|
|
|
|
- border-left: 10px solid transparent;
|
|
|
|
- border-right: 10px solid transparent;
|
|
|
|
- border-bottom: 10px solid #f7f7f7;">
|
|
|
|
|
|
+ </div>
|
|
|
|
|
|
|
|
+ <!-- Reverse Proxy as Default Site Options -->
|
|
|
|
+ <div id="defaultSiteProxyOptions" class="ui basic segment advanceoptions defaultSiteOptionDetails" style="display:none; ">
|
|
|
|
+ <div class="ui form">
|
|
|
|
+ <div class="field">
|
|
|
|
+ <label>Reverse Proxy Target</label>
|
|
|
|
+ <input type="text" id="proxyRoot" onchange="checkRootRequireTLS(this.value);">
|
|
|
|
+ <small>e.g. localhost:8080 / 192.168.0.100:80 / example.com</small>
|
|
|
|
+ </div>
|
|
|
|
+ <div class="field">
|
|
|
|
+ <div class="ui checkbox">
|
|
|
|
+ <input type="checkbox" id="rootReqTLS">
|
|
|
|
+ <label>Reverse proxy target require TLS connection <br><small>Check this if your proxy target URL require connection with https://</small></label>
|
|
|
|
+ </div>
|
|
</div>
|
|
</div>
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
|
|
+
|
|
|
|
+ <!-- Redirect as default site Options-->
|
|
|
|
+ <div id="defaultSiteRedirectOptions" class="ui basic segment advanceoptions defaultSiteOptionDetails" style="display:none;"">
|
|
|
|
+ <div class="ui form">
|
|
<div class="field">
|
|
<div class="field">
|
|
<label>Redirect target domain</label>
|
|
<label>Redirect target domain</label>
|
|
<div class="ui input">
|
|
<div class="ui input">
|
|
@@ -58,40 +69,54 @@
|
|
Leave empty for redirecting to upper level domain (e.g. notfound.example.com <i class="right arrow icon"></i> example.com)</small>
|
|
Leave empty for redirecting to upper level domain (e.g. notfound.example.com <i class="right arrow icon"></i> example.com)</small>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
- <br>
|
|
|
|
- <button class="ui basic button" onclick="updateRootOptions()"><i class="blue save icon" ></i> Save Root Options</button>
|
|
|
|
</div>
|
|
</div>
|
|
- <br>
|
|
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+ <button class="ui basic button" onclick="setProxyRoot()"><i class="green save icon" ></i> Save Options</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<script>
|
|
<script>
|
|
|
|
+ let currentDefaultSiteOption = "webserver";
|
|
$("#advanceRootSettings").accordion();
|
|
$("#advanceRootSettings").accordion();
|
|
|
|
|
|
- function handleUseStaticWebServerAsRoot(){
|
|
|
|
- let useStaticWebServer = $("#useStaticWebServer")[0].checked;
|
|
|
|
- if (useStaticWebServer){
|
|
|
|
|
|
+ //Handle toggle events of option radio boxes
|
|
|
|
+ function updateAvaibleDefaultSiteOptions(){
|
|
|
|
+ let selectedDefaultSite = $('input[name="defaultsiteOption"]:checked').val();
|
|
|
|
+
|
|
|
|
+ $(".defaultSiteOptionDetails").hide();
|
|
|
|
+ if (selectedDefaultSite == "webserver"){
|
|
|
|
+ //Use build in web server as target
|
|
let staticWebServerURL = "127.0.0.1:" + $("#webserv_listenPort").val();
|
|
let staticWebServerURL = "127.0.0.1:" + $("#webserv_listenPort").val();
|
|
$("#proxyRoot").val(staticWebServerURL);
|
|
$("#proxyRoot").val(staticWebServerURL);
|
|
$("#proxyRoot").parent().addClass("disabled");
|
|
$("#proxyRoot").parent().addClass("disabled");
|
|
$("#rootReqTLS").parent().checkbox("set unchecked");
|
|
$("#rootReqTLS").parent().checkbox("set unchecked");
|
|
$("#rootReqTLS").parent().addClass("disabled");
|
|
$("#rootReqTLS").parent().addClass("disabled");
|
|
|
|
|
|
- //Check if web server is enabled. If not, ask if the user want to enable it
|
|
|
|
- /*if (!$("#webserv_enable").parent().checkbox("is checked")){
|
|
|
|
- confirmBox("Enable static web server now?", function(choice){
|
|
|
|
- if (choice == true){
|
|
|
|
- $("#webserv_enable").parent().checkbox("set checked");
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- }*/
|
|
|
|
- }else{
|
|
|
|
|
|
+ }else if (selectedDefaultSite == "proxy"){
|
|
|
|
+ $("#defaultSiteProxyOptions").show();
|
|
$("#rootReqTLS").parent().removeClass("disabled");
|
|
$("#rootReqTLS").parent().removeClass("disabled");
|
|
$("#proxyRoot").parent().removeClass("disabled");
|
|
$("#proxyRoot").parent().removeClass("disabled");
|
|
initRootInfo();
|
|
initRootInfo();
|
|
|
|
+ }else if (selectedDefaultSite == "redirect"){
|
|
|
|
+ $("#defaultSiteRedirectOptions").show();
|
|
|
|
+ }else if (selectedDefaultSite == "notfound"){
|
|
|
|
+
|
|
|
|
+ }else{
|
|
|
|
+ //Unknown option
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ currentDefaultSiteOption = selectedDefaultSite;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //Bind events to the radio boxes
|
|
|
|
+ function bindDefaultSiteRadioCheckboxEvents(){
|
|
|
|
+ $('input[type=radio][name=defaultsiteOption]').change(function() {
|
|
|
|
+ updateAvaibleDefaultSiteOptions();
|
|
|
|
+ });
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
function initRootInfo(callback=undefined){
|
|
function initRootInfo(callback=undefined){
|
|
$.get("/api/proxy/list?type=root", function(data){
|
|
$.get("/api/proxy/list?type=root", function(data){
|
|
if (data == null){
|
|
if (data == null){
|
|
@@ -107,18 +132,22 @@
|
|
});
|
|
});
|
|
}
|
|
}
|
|
initRootInfo(function(){
|
|
initRootInfo(function(){
|
|
- updateWebServerLinkSettings();
|
|
|
|
|
|
+ updateWebServerLinkSettings(function(){
|
|
|
|
+ bindDefaultSiteRadioCheckboxEvents();
|
|
|
|
+ });
|
|
});
|
|
});
|
|
|
|
|
|
//Update the current web server port settings
|
|
//Update the current web server port settings
|
|
- function updateWebServerLinkSettings(){
|
|
|
|
|
|
+ function updateWebServerLinkSettings(callback=undefined){
|
|
isUsingStaticWebServerAsRoot(function(isUsingWebServ){
|
|
isUsingStaticWebServerAsRoot(function(isUsingWebServ){
|
|
if (isUsingWebServ){
|
|
if (isUsingWebServ){
|
|
- $(".webservRootDisabled").addClass("disabled");
|
|
|
|
- $("#useStaticWebServer").parent().checkbox("set checked");
|
|
|
|
|
|
+ //Select the
|
|
}else{
|
|
}else{
|
|
- $(".webservRootDisabled").removeClass("disabled");
|
|
|
|
- $("#useStaticWebServer").parent().checkbox("set unchecked");
|
|
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (callback != undefined){
|
|
|
|
+ callback(isUsingWebServ);
|
|
}
|
|
}
|
|
})
|
|
})
|
|
}
|
|
}
|
|
@@ -150,31 +179,6 @@
|
|
updateRootSettingStates();
|
|
updateRootSettingStates();
|
|
}
|
|
}
|
|
|
|
|
|
- //Toggle the display status of the input box for domain setting
|
|
|
|
- function updateRedirectionDomainSettingInputBox(useRedirect){
|
|
|
|
- if(useRedirect){
|
|
|
|
- $("#unsetRedirectDomainWrapper").stop().finish().slideDown("fast");
|
|
|
|
- }else{
|
|
|
|
- $("#unsetRedirectDomainWrapper").stop().finish().slideUp("fast");
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- function checkCustomRedirectForUnsetSubd(){
|
|
|
|
- $.get("/api/proxy/root/listOptions", function(data){
|
|
|
|
- $("#unsetRedirect")[0].checked = data.EnableRedirectForUnsetRules || false;
|
|
|
|
- $("#unsetRedirectDomain").val(data.UnsetRuleRedirectTarget);
|
|
|
|
- updateRedirectionDomainSettingInputBox(data.EnableRedirectForUnsetRules);
|
|
|
|
-
|
|
|
|
- //Bind event to the checkbox
|
|
|
|
- $("#unsetRedirect").off("change").on("change", function(){
|
|
|
|
- let useRedirect = $("#unsetRedirect")[0].checked;
|
|
|
|
- updateRedirectionDomainSettingInputBox(useRedirect);
|
|
|
|
- });
|
|
|
|
- });
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- checkCustomRedirectForUnsetSubd();
|
|
|
|
-
|
|
|
|
//Check if the given domain will redirect to https
|
|
//Check if the given domain will redirect to https
|
|
function checkRootRequireTLS(targetDomain){
|
|
function checkRootRequireTLS(targetDomain){
|
|
//Trim off the http or https from the origin
|
|
//Trim off the http or https from the origin
|