rules.html 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <h3><i class="ui exchange icon"></i> New Proxy Endpoint</h3>
  2. <p>You can create a proxy endpoing by subdomain or virtual directories</p>
  3. <div class="ui form">
  4. <div class="field">
  5. <label>Proxy Type</label>
  6. <div class="ui selection dropdown">
  7. <input type="hidden" id="ptype" value="subd">
  8. <i class="dropdown icon"></i>
  9. <div class="default text">Proxy Type</div>
  10. <div class="menu">
  11. <div class="item" data-value="subd">Sub-domain</div>
  12. <div class="item" data-value="vdir">Virtual Directory</div>
  13. </div>
  14. </div>
  15. </div>
  16. <div class="field">
  17. <label>Subdomain Matching Keyword / Virtual Directory Name</label>
  18. <input type="text" id="rootname" placeholder="s1.mydomain.com">
  19. <div class="ui message">
  20. Example of subdomain matching keyword:<br>
  21. <code>s1.arozos.com</code> <br>(Any access starting with s1.arozos.com will be proxy to the IP address below)<br>
  22. Example of virtual directory name: <br>
  23. <code>/s1/home</code> <br>(Any access to {this_server}/s1/ will be proxy to the IP address below)
  24. </div>
  25. </div>
  26. <div class="field">
  27. <label>IP Address or Domain Name with port</label>
  28. <input type="text" id="proxyDomain">
  29. <small>E.g. 192.168.0.101:8000 or example.com</small>
  30. </div>
  31. <div class="field">
  32. <div class="ui checkbox">
  33. <input type="checkbox" id="reqTls">
  34. <label>Proxy Target require TLS Connection <br><small>(i.e. Your proxy target starts with https://)</small></label>
  35. </div>
  36. </div>
  37. <button class="ui teal button" onclick="newProxyEndpoint();">Create Proxy Endpoint</button>
  38. </div>
  39. <div class="ui green message" id="proxyaddSucc" style="display:none">
  40. <i class="ui checkmark icon"></i> Proxy Endpoint Added
  41. </div>
  42. <script>
  43. //New Proxy Endpoint
  44. function newProxyEndpoint(){
  45. var type = $("#ptype").val();
  46. var rootname = $("#rootname").val();
  47. var proxyDomain = $("#proxyDomain").val();
  48. var useTLS = $("#reqTls")[0].checked;
  49. if (rootname.trim() == ""){
  50. $("#rootname").parent().addClass("error");
  51. return
  52. }else{
  53. $("#rootname").parent().removeClass("error");
  54. }
  55. if (proxyDomain.trim() == ""){
  56. $("#proxyDomain").parent().addClass("error");
  57. return
  58. }else{
  59. $("#proxyDomain").parent().removeClass("error");
  60. }
  61. //Create the endpoint by calling add
  62. $.ajax({
  63. url: "/api/proxy/add",
  64. data: {type: type, rootname: rootname, tls: useTLS, ep: proxyDomain},
  65. success: function(data){
  66. if (data.error != undefined){
  67. alert(data.error);
  68. }else{
  69. //OK
  70. listVdirs();
  71. listSubd();
  72. $("#proxyaddSucc").stop().slideDown('fast').delay(3000).slideUp('fast');
  73. //Clear old data
  74. $("#rootname").val("");
  75. $("#proxyDomain").val("");
  76. }
  77. }
  78. });
  79. }
  80. //Generic functions for delete rp endpoints
  81. function deleteEndpoint(ptype, epoint){
  82. if (confirm("Confirm remove proxy for :" + epoint + " (type: " + ptype + ")?")){
  83. $.ajax({
  84. url: "/api/proxy/del",
  85. data: {ep: epoint, ptype: ptype},
  86. success: function(){
  87. listVdirs();
  88. listSubd();
  89. }
  90. })
  91. }
  92. }
  93. </script>