diff --git a/src/mod/dynamicproxy/proxyRequestHandler.go b/src/mod/dynamicproxy/proxyRequestHandler.go index dba00bd..24dbfc2 100644 --- a/src/mod/dynamicproxy/proxyRequestHandler.go +++ b/src/mod/dynamicproxy/proxyRequestHandler.go @@ -361,7 +361,7 @@ func (router *Router) logRequest(r *http.Request, succ bool, statusCode int, for // in that case we will log it by default and will not enter this routine return } - if router.Option.StatisticCollector != nil { + if router.Option.StatisticCollector != nil && !endpoint.DisableStatisticCollection { go func() { requestInfo := statistic.RequestInfo{ IpAddr: netutils.GetRequesterIP(r), @@ -377,6 +377,7 @@ func (router *Router) logRequest(r *http.Request, succ bool, statusCode int, for } router.Option.StatisticCollector.RecordRequest(requestInfo) }() + } router.Option.Logger.LogHTTPRequest(r, forwardType, statusCode, originalHostname, upstreamHostname) } diff --git a/src/mod/dynamicproxy/typedef.go b/src/mod/dynamicproxy/typedef.go index 414b6d7..d207a86 100644 --- a/src/mod/dynamicproxy/typedef.go +++ b/src/mod/dynamicproxy/typedef.go @@ -207,8 +207,9 @@ type ProxyEndpoint struct { RateLimit int64 // Rate limit in requests per second //Uptime Monitor - DisableUptimeMonitor bool //Disable uptime monitor for this endpoint - DisableLogging bool //Disable logging of reverse proxy requests + DisableUptimeMonitor bool //Disable uptime monitor for this endpoint + DisableLogging bool //Disable logging of reverse proxy requests + DisableStatisticCollection bool //Disable statistic collection for this endpoint // Chunked Transfer Encoding DisableChunkedTransferEncoding bool //Disable chunked transfer encoding for this endpoint diff --git a/src/reverseproxy.go b/src/reverseproxy.go index 652ae66..8e9cf77 100644 --- a/src/reverseproxy.go +++ b/src/reverseproxy.go @@ -577,6 +577,9 @@ func ReverseProxyHandleEditEndpoint(w http.ResponseWriter, r *http.Request) { // Disable logging disableLogging, _ := utils.PostBool(r, "dLogging") + // Disable statistic collection + disableStatisticCollection, _ := utils.PostBool(r, "dStatisticCollection") + //Load the previous basic auth credentials from current proxy rules targetProxyEntry, err := dynamicProxyRouter.LoadProxy(rootNameOrMatchingDomain) if err != nil { @@ -619,6 +622,7 @@ func ReverseProxyHandleEditEndpoint(w http.ResponseWriter, r *http.Request) { newProxyEndpoint.DisableUptimeMonitor = disbleUtm newProxyEndpoint.DisableChunkedTransferEncoding = disableChunkedEncoding newProxyEndpoint.DisableLogging = disableLogging + newProxyEndpoint.DisableStatisticCollection = disableStatisticCollection newProxyEndpoint.Tags = tags //Prepare to replace the current routing rule diff --git a/src/web/components/httprp.html b/src/web/components/httprp.html index 15de241..0e3e3d3 100644 --- a/src/web/components/httprp.html +++ b/src/web/components/httprp.html @@ -290,6 +290,13 @@ +
+
+ + +
+
@@ -892,6 +899,7 @@ let bypassGlobalTLS = $(editor).find(".BypassGlobalTLS")[0].checked; let disableChunkedTransferEncoding = $(editor).find(".DisableChunkedTransferEncoding")[0].checked; let disableLogging = $(editor).find(".DisableLogging")[0].checked; + let disableStatisticCollection = $(editor).find(".DisableStatisticCollection")[0].checked; let tags = getTagsArrayFromEndpoint(uuid); if (tags.length > 0){ tags = tags.join(","); @@ -909,6 +917,7 @@ "rate" :requireRateLimit, "dChunkedEnc": disableChunkedTransferEncoding, "dLogging": disableLogging, + "dStatisticCollection": disableStatisticCollection, "ratenum" :rateLimit, "tags": tags, }; @@ -1250,8 +1259,25 @@ editor.find(".DisableLogging").off('change'); editor.find(".DisableLogging").prop("checked", subd.DisableLogging); editor.find(".DisableLogging").on("change", function() { + // When logging is disabled, also disable statistic collection + if ($(this).is(':checked')) { + editor.find(".DisableStatisticCollection").prop("checked", true).prop("disabled", true); + } else { + editor.find(".DisableStatisticCollection").prop("disabled", false); + } saveProxyInlineEdit(uuid); }); + + editor.find(".DisableStatisticCollection").off('change'); + editor.find(".DisableStatisticCollection").prop("checked", subd.DisableStatisticCollection); + editor.find(".DisableStatisticCollection").on("change", function() { + saveProxyInlineEdit(uuid); + }); + + // Handle initial state: if logging is disabled, disable statistic collection + if (subd.DisableLogging) { + editor.find(".DisableStatisticCollection").prop("checked", true).prop("disabled", true); + } //Bind the edit button editor.find(".downstream_primary_hostname_edit_btn").off("click").on("click", function(){