rproot.html 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <div class="standardContainer">
  2. <div class="ui basic segment">
  3. <h2>Set Proxy Root</h2>
  4. <p>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. </div>
  18. <br>
  19. <button class="ui basic button" onclick="setProxyRoot()"><i class="teal home icon" ></i> Update Proxy Root</button>
  20. </div>
  21. </div>
  22. <script>
  23. function initRootInfo(){
  24. $.get("/api/proxy/list?type=root", function(data){
  25. if (data == null){
  26. }else{
  27. $("#proxyRoot").val(data.Domain);
  28. checkRootRequireTLS(data.Domain);
  29. }
  30. });
  31. }
  32. initRootInfo();
  33. function checkRootRequireTLS(targetDomain){
  34. $.ajax({
  35. url: "/api/proxy/tlscheck",
  36. data: {url: targetDomain},
  37. success: function(data){
  38. if (data.error != undefined){
  39. }else if (data == "https"){
  40. $("#rootReqTLS").parent().checkbox("set checked");
  41. }else if (data == "http"){
  42. $("#rootReqTLS").parent().checkbox("set unchecked");
  43. }
  44. }
  45. })
  46. }
  47. function setProxyRoot(){
  48. var newpr = $("#proxyRoot").val();
  49. if (newpr.trim() == ""){
  50. $("#proxyRoot").parent().addClass('error');
  51. return
  52. }else{
  53. $("#proxyRoot").parent().removeClass('error');
  54. }
  55. var rootReqTls = $("#rootReqTLS")[0].checked;
  56. //Create the endpoint by calling add
  57. $.ajax({
  58. url: "/api/proxy/add",
  59. data: {"type": "root", tls: rootReqTls, ep: newpr},
  60. success: function(data){
  61. if (data.error != undefined){
  62. alert(data.error);
  63. }else{
  64. //OK
  65. initRootInfo();
  66. msgbox("Proxy Root Updated")
  67. }
  68. }
  69. });
  70. }
  71. </script>