123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187 |
- <div class="standardContainer">
- <div class="ui basic segment">
- <h2>Set Proxy Root</h2>
- <p>The default routing point for all incoming traffics. For all routing not found in the proxy rules, request will be redirected to the proxy root server.</p>
- <div class="ui form">
- <div class="field">
- <label>Proxy Root</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>Root require TLS connection <br><small>Check this if your proxy root URL starts with https://</small></label>
- </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>
- </div>
- <div class="ui basic segment" id="unsetRedirectDomain" 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>
- <div class="field">
- <label>Redirect target domain</label>
- <div class="ui input">
- <input type="text" placeholder="http://example.com">
- </div>
- <small>Unset subdomain will be redirected to the link above. Remember to include the protocol (e.g. http:// or https://)<br>
- 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 class="field">
- <div class="ui checkbox">
- <input type="checkbox" id="disableRootTLS">
- <label>Disable https on proxy root <br><small>Check this if you want your proxy root to bypass global TLS setting (Not Recommend)</small></label>
- </div>
- </div>
- <br>
- <button class="ui basic button" onclick="updateRootOptions()"><i class="blue save icon" ></i> Save Root Options</button>
- </div>
- <br>
-
- </div>
- </div>
- <script>
- $("#advanceRootSettings").accordion();
- function initRootInfo(){
- $.get("/api/proxy/list?type=root", function(data){
- if (data == null){
- }else{
- $("#proxyRoot").val(data.Domain);
- checkRootRequireTLS(data.Domain);
- }
- });
-
- }
- initRootInfo();
- function updateRootSettingStates(){
- $.get("/api/cert/tls", function(data){
- if (data == true){
- $("#disableRootTLS").parent().removeClass('disabled').attr("title", "");
- }else{
- $("#disableRootTLS").parent().addClass('disabled').attr("title", "TLS listener is not enabled");
- }
- });
- }
-
- tabSwitchEventBind["setroot"] = function(){
-
- updateRootSettingStates();
- }
-
- function updateRedirectionDomainSettingInputBox(useRedirect){
- if(useRedirect){
- $("#unsetRedirectDomain").stop().finish().slideDown("fast");
- }else{
- $("#unsetRedirectDomain").stop().finish().slideUp("fast");
- }
- }
- function checkCustomRedirectForUnsetSubd(){
- $("#unsetRedirect").on("change", function(){
- let useRedirect = $(this)[0].checked;
- updateRedirectionDomainSettingInputBox(useRedirect);
-
- })
- }
- checkCustomRedirectForUnsetSubd();
- function checkRootRequireTLS(targetDomain){
-
- if (targetDomain.startsWith("http://")){
- targetDomain = targetDomain.substring(7);
- $("#proxyRoot").val(targetDomain);
- }else if (targetDomain.startsWith("https://")){
- targetDomain = targetDomain.substring(8);
- $("#proxyRoot").val(targetDomain);
- }
- $.ajax({
- url: "/api/proxy/tlscheck",
- data: {url: targetDomain},
- success: function(data){
- if (data.error != undefined){
- }else if (data == "https"){
- $("#rootReqTLS").parent().checkbox("set checked");
- }else if (data == "http"){
- $("#rootReqTLS").parent().checkbox("set unchecked");
- }
-
- }
- })
- }
- function setProxyRoot(){
- var newpr = $("#proxyRoot").val();
- if (newpr.trim() == ""){
- $("#proxyRoot").parent().addClass('error');
- return
- }else{
- $("#proxyRoot").parent().removeClass('error');
- }
- var rootReqTls = $("#rootReqTLS")[0].checked;
-
- $.ajax({
- url: "/api/proxy/add",
- data: {"type": "root", tls: rootReqTls, ep: newpr},
- success: function(data){
- if (data.error != undefined){
- alert(data.error);
- }else{
-
- initRootInfo();
- msgbox("Proxy Root Updated")
- }
- }
- });
- }
- function updateRootOptions(){
- const jsonData = {
-
- };
- $.ajax({
- type: "POST",
- url: "/api/proxy/root/updateOptions",
- contentType: "application/json",
- data: JSON.stringify(jsonData),
- success: function(response) {
- console.log("Success:", response);
- },
- error: function(error) {
- console.log("Error:", error);
- }
- });
- }
- </script>
|