123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239 |
- <!DOCTYPE html>
- <html>
- <head>
- <meta name="apple-mobile-web-app-capable" content="yes" />
- <meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1, maximum-scale=1"/>
- <meta charset="UTF-8">
- <meta name="theme-color" content="#4b75ff">
- <link rel="icon" type="image/png" href="img/small_icon.png"/>
- <link rel="stylesheet" href="script/semantic/semantic.min.css">
- <script src="script/jquery-3.6.0.min.js"></script>
- <script src="../script/ao_module.js"></script>
- <script src="script/semantic/semantic.min.js"></script>
- <title>Reverse Proxy</title>
- <style>
- body{
- background-color:white;
- }
-
- .functiontab{
- display:none;
- }
- </style>
- </head>
- <body>
- <br>
- <div class="ui container">
- <h3><img class="ui middle aligned mini image" src="img/small_icon.png" style="margin-right:1em;"> Reverse Proxy Settings</h3>
- <div class="ui divider"></div>
- <div id="errmsg" class="ui red message" style="display: none;"></div>
- <div class="ui stackable grid">
- <div class="four wide column">
- <div id="mainmenu" class="ui secondary vertical pointing menu">
- <a class="item active" tag="status">
- <i class="info circle icon"></i>Status
- </a>
- <a class="item" tag="vdir">
- <i class="folder icon"></i> Virtual Directory
- </a>
- <a class="item" tag="subd">
- <i class="sitemap icon"></i> Subdomain Proxy
- </a>
- <a class="item" tag="rules">
- <i class="plus square icon"></i> Create Proxy Rules
- </a>
- <a class="item" tag="setroot">
- <i class="home icon"></i> Set Proxy Root
- </a>
- <div class="ui divider"></div>
- <a class="item" tag="cert">
- <i class="lock icon"></i> TLS / SSL certificate
- </a>
- <a class="item" tag="redirectset">
- <i class="level up alternate icon"></i> Redirection
- </a>
- </div>
- </div>
- <div class="twelve wide column">
- <!-- Status Tab -->
- <div id="status" class="functiontab" target="status.html" style="display: block ;">
- <br><br><div class="ui active centered inline loader"></div>
- </div>
- <!-- Virtual Directory Tab -->
- <div id="vdir" class="functiontab" target="vdir.html"></div>
- <!-- Subdomain Proxy -->
- <div id="subd" class="functiontab" target="subd.html"></div>
- <!-- Create Rules -->
- <div id="rules" class="functiontab" target="rules.html"></div>
- <!-- Set proxy root -->
- <div id="setroot" class="functiontab" target="rproot.html"></div>
- <!-- Set TLS cert -->
- <div id="cert" class="functiontab" target="cert.html"></div>
- <!-- Redirections -->
- <div id="redirectset" class="functiontab" target="redirection.html"></div>
- </div>
- </div>
- </div>
- <br><br>
- <div class="ui divider"></div>
- <div class="ui container" style="color: grey; font-size: 90%">
- <p>Reverse Proxy Subservice. CopyRight imuslab, Licensed under MIT</p>
- </div>
-
- </div>
- <br><br>
- <script>
- /*
- Loader function
- Load all the components view from the
- components/ directory into their corrisponding divs
- */
- let loadingComponents = 0;
- function initTabs(callback=undefined){
- $('.functiontab').each(function(){
- let loadTarget = $(this).attr("target");
- if (loadTarget != undefined){
- $(this).load("./components/" + loadTarget, function(){
- loadingComponents--;
- });
- loadingComponents++;
- }else{
- $(this).html(`<p>Unable to load components for this tab</p>`);
- }
- })
- if (callback != undefined){
- waitInit(callback);
- }
- }
- function waitInit(callback = undefined, retryCount = 0){
- if (loadingComponents > 0 && retryCount < 5){
- setTimeout(function(){
- waitInit(callback, retryCount++);
- }, 300);
- }else if (loadingComponents == 0){
- callback();
- }else{
- alert("Missing component. Please check if your installation is complete.")
- }
- }
- initTabs(function(){
- initRPStaste();
- if (window.location.hash.length > 1){
- let tabID = window.location.hash.substr(1);
- openTabById(tabID);
- }else{
- openTabById("status");
- }
- $(".ui.dropdown").dropdown();
- $(".ui.checkbox").checkbox();
- //Click on the current tab
- $("#mainmenu").find(".item").each(function(){
- $(this).on("click", function(event){
- let tabid = $(this).attr("tag");
- openTabById(tabid);
- });
- });
- });
- function getTabButtonById(targetTabId){
- let targetTabBtn = undefined;
- $("#mainmenu").find(".item").each(function(){
- let tabid = $(this).attr("tag");
-
- if (tabid == targetTabId){
- targetTabBtn = $(this);
- }
- });
- return targetTabBtn;
- }
- //Select and open a tab by its tag id
- function openTabById(tabID){
- let targetBtn = getTabButtonById(tabID);
- if (targetBtn == undefined){
- alert("Invalid tabid given");
- return;
- }
- $("#mainmenu").find(".item").removeClass("active");
- $(targetBtn).addClass("active");
- $(".functiontab").hide();
- $("#" + tabID).fadeIn('fast');
- $('html,body').animate({scrollTop: 0}, 'fast');
- window.location.hash = tabID;
- }
-
- //Generic functions
- function deleteEndpoint(ptype, epoint){
- if (confirm("Confirm remove proxy for :" + epoint + " (type: " + ptype + ")?")){
- $.ajax({
- url: "./del",
- data: {ep: epoint, ptype: ptype},
- success: function(){
- listVdirs();
- listSubd();
- }
- })
- }
-
- }
-
-
-
-
-
- function setProxyRoot(){
- var newpr = $("#proxyRoot").val();
- if (newpr.trim() == ""){
- $("#proxyRoot").parent().addClass('error');
- return
- }else{
- $("#proxyRoot").parent().removeClass('error');
- }
- var rootReqTls = $("#rootReqTLS")[0].checked;
- //Create the endpoint by calling add
- $.ajax({
- url: "./add",
- data: {"type": "root", tls: rootReqTls, ep: newpr},
- success: function(data){
- if (data.error != undefined){
- alert(data.error);
- }else{
- //OK
- initRootInfo();
- $("#ProxyRootUpdate").stop().slideDown('fast').delay(3000).slideUp('fast');
- }
- }
- });
- }
-
- //Show error message
- function errmsg(message){
- $("#errmsg").html(`<i class="red remove icon"></i> ${message}`);
- $("#errmsg").slideDown('fast').delay(5000).slideUp('fast');
- }
- </script>
- </body>
- </html>
|