rproot.html 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <div class="standardContainer">
  2. <div class="ui basic segment">
  3. <h2>Set Proxy Root</h2>
  4. <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>
  5. <div class="ui form">
  6. <div class="field">
  7. <label>Proxy Root</label>
  8. <input type="text" id="proxyRoot" onchange="checkRootRequireTLS(this.value);">
  9. <small>E.g. localhost:8080</small>
  10. </div>
  11. <div class="field">
  12. <div class="ui checkbox">
  13. <input type="checkbox" id="rootReqTLS">
  14. <label>Root require TLS Connection <br><small>(i.e. Your proxy target starts with https://)</small></label>
  15. </div>
  16. </div>
  17. <br>
  18. <button class="ui basic button" onclick="setProxyRoot()"><i class="teal home icon" ></i> Update Proxy Root</button>
  19. <!-- Advance configs -->
  20. <div class="ui basic segment" style="background-color: #f7f7f7; border-radius: 1em;">
  21. <div id="advanceRootSettings" class="ui fluid accordion">
  22. <div class="title">
  23. <i class="dropdown icon"></i>
  24. Advance Root Routing Settings
  25. </div>
  26. <div class="content">
  27. <h4>Force Root Redirect for Unset Sub-domains</h4>
  28. <p>Enabling this option will force redirect user back to root if the user is requesting a sub-domain that is not registered in this layer of reverse proxy. <br>
  29. (Recommend for top-level reverse proxy setup only)</p>
  30. <div class="field">
  31. <div class="ui checkbox">
  32. <input type="checkbox" id="forceUnsetSubdRedirect">
  33. <label>Enable force redirect</label>
  34. </div>
  35. </div>
  36. <div class="ui divider"></div>
  37. </div>
  38. </div>
  39. </div>
  40. </div>
  41. <br>
  42. </div>
  43. </div>
  44. <script>
  45. $("#advanceRootSettings").accordion();
  46. function initRootInfo(){
  47. $.get("/api/proxy/list?type=root", function(data){
  48. if (data == null){
  49. }else{
  50. $("#proxyRoot").val(data.Domain);
  51. checkRootRequireTLS(data.Domain);
  52. }
  53. });
  54. }
  55. initRootInfo();
  56. function checkRootRequireTLS(targetDomain){
  57. $.ajax({
  58. url: "/api/proxy/tlscheck",
  59. data: {url: targetDomain},
  60. success: function(data){
  61. if (data.error != undefined){
  62. }else if (data == "https"){
  63. $("#rootReqTLS").parent().checkbox("set checked");
  64. }else if (data == "http"){
  65. $("#rootReqTLS").parent().checkbox("set unchecked");
  66. }
  67. //Trim off the http or https from the origin
  68. if (targetDomain.startsWith("http://")){
  69. targetDomain = targetDomain.substring(7);
  70. $("#proxyRoot").val(targetDomain);
  71. }else if (targetDomain.startsWith("https://")){
  72. targetDomain = targetDomain.substring(8);
  73. $("#proxyRoot").val(targetDomain);
  74. }
  75. }
  76. })
  77. }
  78. function setProxyRoot(){
  79. var newpr = $("#proxyRoot").val();
  80. if (newpr.trim() == ""){
  81. $("#proxyRoot").parent().addClass('error');
  82. return
  83. }else{
  84. $("#proxyRoot").parent().removeClass('error');
  85. }
  86. var rootReqTls = $("#rootReqTLS")[0].checked;
  87. //Create the endpoint by calling add
  88. $.ajax({
  89. url: "/api/proxy/add",
  90. data: {"type": "root", tls: rootReqTls, ep: newpr},
  91. success: function(data){
  92. if (data.error != undefined){
  93. alert(data.error);
  94. }else{
  95. //OK
  96. initRootInfo();
  97. msgbox("Proxy Root Updated")
  98. }
  99. }
  100. });
  101. }
  102. </script>