diff --git a/src/api.go b/src/api.go
index 458a002..762f1f9 100644
--- a/src/api.go
+++ b/src/api.go
@@ -47,6 +47,7 @@ func initAPIs() {
authRouter.HandleFunc("/api/proxy/enable", ReverseProxyHandleOnOff)
authRouter.HandleFunc("/api/proxy/add", ReverseProxyHandleAddEndpoint)
authRouter.HandleFunc("/api/proxy/status", ReverseProxyStatus)
+ authRouter.HandleFunc("/api/proxy/toggle", ReverseProxyToggleRuleSet)
authRouter.HandleFunc("/api/proxy/list", ReverseProxyList)
authRouter.HandleFunc("/api/proxy/edit", ReverseProxyHandleEditEndpoint)
authRouter.HandleFunc("/api/proxy/del", DeleteProxyEndpoint)
diff --git a/src/mod/dynamicproxy/Server.go b/src/mod/dynamicproxy/Server.go
index 7676210..2e3766e 100644
--- a/src/mod/dynamicproxy/Server.go
+++ b/src/mod/dynamicproxy/Server.go
@@ -193,7 +193,15 @@ func (h *ProxyHandler) handleRootRouting(w http.ResponseWriter, r *http.Request)
h.logRequest(r, false, 307, "root-redirect", domainOnly)
http.Redirect(w, r, redirectTarget, http.StatusTemporaryRedirect)
case DefaultSite_NotFoundPage:
- http.NotFound(w, r)
+ //Serve the not found page, use template if exists
+ w.Header().Set("Content-Type", "text/html; charset=utf-8")
+ w.WriteHeader(http.StatusNotFound)
+ template, err := os.ReadFile(filepath.Join(h.Parent.Option.WebDirectory, "templates/notfound.html"))
+ if err != nil {
+ w.Write(page_hosterror)
+ } else {
+ w.Write(template)
+ }
}
}
diff --git a/src/mod/dynamicproxy/templates/hosterror.html b/src/mod/dynamicproxy/templates/hosterror.html
new file mode 100644
index 0000000..aef97d3
--- /dev/null
+++ b/src/mod/dynamicproxy/templates/hosterror.html
@@ -0,0 +1,157 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 404 - Host Not Found
+
+
+
+
+
+
+
Error 404
+
Target Host Not Found
+
+
+
+
+
+
+
+
+
+
You
+
+
Working
+
+
+
+
+
+
+
+
Gateway Node
+
+
Working
+
+
+
+
+
+
+
+
+
Not Found
+
+
+
+
+
+
+
+
+
+
What happend?
+
The reverse proxy target domain is not found.
For more information, see the error message on the reverse proxy terminal.
+
+
+
What can I do?
+
If you are a visitor of this website:
+
Please try again in a few minutes
+
If you are the owner of this website:
+
+
Check if the proxy rules that match this hostname exists
+
Visit the Reverse Proxy management interface to correct any setting errors
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/mod/dynamicproxy/typedef.go b/src/mod/dynamicproxy/typedef.go
index d67b808..7e93831 100644
--- a/src/mod/dynamicproxy/typedef.go
+++ b/src/mod/dynamicproxy/typedef.go
@@ -143,4 +143,6 @@ Web Templates
var (
//go:embed templates/forbidden.html
page_forbidden []byte
+ //go:embed templates/hosterror.html
+ page_hosterror []byte
)
diff --git a/src/reverseproxy.go b/src/reverseproxy.go
index 0454992..b7b95b4 100644
--- a/src/reverseproxy.go
+++ b/src/reverseproxy.go
@@ -702,11 +702,44 @@ func RemoveProxyBasicAuthExceptionPaths(w http.ResponseWriter, r *http.Request)
utils.SendOK(w)
}
+// Report the current status of the reverse proxy server
func ReverseProxyStatus(w http.ResponseWriter, r *http.Request) {
js, _ := json.Marshal(dynamicProxyRouter)
utils.SendJSONResponse(w, string(js))
}
+// Toggle a certain rule on and off
+func ReverseProxyToggleRuleSet(w http.ResponseWriter, r *http.Request) {
+ //No need to check for type as root cannot be turned off
+ ep, err := utils.PostPara(r, "ep")
+ if err != nil {
+ utils.SendErrorResponse(w, "invalid ep given")
+ return
+ }
+
+ targetProxyRule, err := dynamicProxyRouter.LoadProxy(ep)
+ if err != nil {
+ utils.SendErrorResponse(w, "invalid endpoint given")
+ return
+ }
+
+ enableStr, err := utils.PostPara(r, "enable")
+ if err != nil {
+ enableStr = "true"
+ }
+
+ //Flip the enable and disabled tag state
+ ruleDisabled := enableStr == "false"
+
+ targetProxyRule.Disabled = ruleDisabled
+ err = SaveReverseProxyConfig(targetProxyRule)
+ if err != nil {
+ utils.SendErrorResponse(w, "unable to save updated rule")
+ return
+ }
+ utils.SendOK(w)
+}
+
func ReverseProxyList(w http.ResponseWriter, r *http.Request) {
eptype, err := utils.PostPara(r, "type") //Support root and host
if err != nil {
diff --git a/src/web/components/httprp.html b/src/web/components/httprp.html
index 0af8ded..e49b174 100644
--- a/src/web/components/httprp.html
+++ b/src/web/components/httprp.html
@@ -3,6 +3,11 @@
HTTP Proxy
Proxy HTTP server with HTTP or HTTPS for multiple hosts. If you are only proxying for one host / domain, use Default Site instead.
+
@@ -68,14 +73,23 @@
vdList = ` No Virtual Directory`;
}
+ var enableChecked = "checked";
+ if (subd.Disabled){
+ enableChecked = "";
+ }
+
$("#httpProxyList").append(`
${subd.RootOrMatchingDomain} ${inboundTlsIcon} |
${subd.Domain} ${tlsIcon} |
${vdList} |
${subd.RequireBasicAuth?``:``} |
-
-
+
+
+
+
+
+
|
`);
});
@@ -276,8 +290,28 @@
showSideWrapper("snippet/customHeaders.html?t=" + Date.now() + "#" + payload);
}
- function editLoadBalanceOptions(uuid){
- alert(uuid);
+ function handleProxyRuleToggle(object){
+ let endpointUUID = $(object).attr("eptuuid");
+ let isChecked = object.checked;
+ $.ajax({
+ url: "/api/proxy/toggle",
+ data: {
+ "ep": endpointUUID,
+ "enable": isChecked
+ },
+ success: function(data){
+ if (data.error != undefined){
+ msgbox(data.error, false);
+ }else{
+ if (isChecked){
+ msgbox("Proxy Rule Enabled");
+ }else{
+ msgbox("Proxy Rule Disabled");
+ }
+
+ }
+ }
+ })
}
diff --git a/src/web/notfound.html b/src/web/notfound.html
new file mode 100644
index 0000000..d75b91f
--- /dev/null
+++ b/src/web/notfound.html
@@ -0,0 +1,55 @@
+
+
+
+
+
+
+
+
+ Not Found
+
+
+
+
+
+
+
404 - Not Found
+
+
The requested URL was not found on this server
+
+
+
+ Request time:
+ Request URI:
+
+
+
+
+
+