From bb9deccff67042b519a893606abff5db8b433531 Mon Sep 17 00:00:00 2001 From: kirari04 Date: Mon, 24 Jun 2024 22:59:51 +0200 Subject: [PATCH 1/4] fix: unable to edit proxy if ratelimit is not set or <= 0 this fix checks the ratelimit value only if the requireRateLimit is set to true else it will use the provided ratelimit value unless it is less or equal to 0 then it will default to 1000 (the same value as set inside the ui) --- src/reverseproxy.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/reverseproxy.go b/src/reverseproxy.go index 2292ab9..29162ab 100644 --- a/src/reverseproxy.go +++ b/src/reverseproxy.go @@ -475,9 +475,11 @@ func ReverseProxyHandleEditEndpoint(w http.ResponseWriter, r *http.Request) { utils.SendErrorResponse(w, "invalid rate limit number") return } - if proxyRateLimit <= 0 { + if requireRateLimit && proxyRateLimit <= 0 { utils.SendErrorResponse(w, "rate limit number must be greater than 0") return + } else if proxyRateLimit < 0 { + proxyRateLimit = 1000 } // Bypass WebSocket Origin Check From 1a4a55721f83dc3a655f35a287f79ea4d8d7207d Mon Sep 17 00:00:00 2001 From: kirari04 Date: Mon, 24 Jun 2024 23:32:38 +0200 Subject: [PATCH 2/4] Improve Docker Image Size by 500mb by using 2 stage build --- docker/Dockerfile | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index fc354ce..8003330 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,4 +1,4 @@ -FROM docker.io/golang:alpine +FROM docker.io/golang:alpine AS build RUN apk add --no-cache bash netcat-openbsd sudo @@ -8,16 +8,28 @@ RUN mkdir -p /opt/zoraxy/source/ &&\ RUN chmod -R 770 /opt/zoraxy/ -VOLUME [ "/opt/zoraxy/config/" ] - # If you build it yourself, you will need to add the src directory into the docker directory. COPY ./src/ /opt/zoraxy/source/ WORKDIR /opt/zoraxy/source/ RUN go mod tidy &&\ - go build -o /usr/local/bin/zoraxy &&\ - rm -r /opt/zoraxy/source/ +go build -o /usr/local/bin/zoraxy &&\ +rm -r /opt/zoraxy/source/ + +FROM docker.io/alpine:3.20 + +RUN apk add --no-cache bash netcat-openbsd sudo + +RUN mkdir -p /opt/zoraxy/source/ &&\ +mkdir -p /opt/zoraxy/config/ &&\ +mkdir -p /usr/local/bin/ + +VOLUME [ "/opt/zoraxy/config/" ] + +RUN chmod -R 770 /opt/zoraxy/ + +COPY --from=build /usr/local/bin/zoraxy /usr/local/bin/zoraxy RUN chmod 755 /usr/local/bin/zoraxy &&\ chmod +x /usr/local/bin/zoraxy @@ -40,5 +52,4 @@ ENV ZTPORT="9993" ENTRYPOINT "zoraxy" "-docker=true" "-autorenew=${AUTORENEW}" "-fastgeoip=${FASTGEOIP}" "-log=${LOG}" "-mdns=${MDNS}" "-mdnsname=${MDNSNAME}" "-noauth=${NOAUTH}" "-port=:${PORT}" "-sshlb=${SSHLB}" "-version=${VERSION}" "-webfm=${WEBFM}" "-webroot=${WEBROOT}" "-ztauth=${ZTAUTH}" "-ztport=${ZTPORT}" -HEALTHCHECK --interval=15s --timeout=5s --start-period=10s --retries=3 CMD nc -vz 127.0.0.1 $PORT || exit 1 - +HEALTHCHECK --interval=15s --timeout=5s --start-period=10s --retries=3 CMD nc -vz 127.0.0.1 $PORT || exit 1 \ No newline at end of file From 100cd727fc09e4e0f697e8ab8b932bcf9b2b6695 Mon Sep 17 00:00:00 2001 From: kirari04 Date: Wed, 26 Jun 2024 19:54:35 +0200 Subject: [PATCH 3/4] format docker file --- docker/Dockerfile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 8003330..5a5022a 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -14,16 +14,16 @@ COPY ./src/ /opt/zoraxy/source/ WORKDIR /opt/zoraxy/source/ RUN go mod tidy &&\ -go build -o /usr/local/bin/zoraxy &&\ -rm -r /opt/zoraxy/source/ + go build -o /usr/local/bin/zoraxy &&\ + rm -r /opt/zoraxy/source/ FROM docker.io/alpine:3.20 RUN apk add --no-cache bash netcat-openbsd sudo RUN mkdir -p /opt/zoraxy/source/ &&\ -mkdir -p /opt/zoraxy/config/ &&\ -mkdir -p /usr/local/bin/ + mkdir -p /opt/zoraxy/config/ &&\ + mkdir -p /usr/local/bin/ VOLUME [ "/opt/zoraxy/config/" ] From e3b61868a1da60b3db2a01d741492ddb58c21220 Mon Sep 17 00:00:00 2001 From: Kegelcizer Date: Fri, 28 Jun 2024 11:23:35 +0300 Subject: [PATCH 4/4] Update Dockerfile Created folders and set permissions at build stage. Install stuff and copy only required folders with permissions already set at build stage. --- docker/Dockerfile | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 5a5022a..8d6ed44 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,7 +1,5 @@ FROM docker.io/golang:alpine AS build -RUN apk add --no-cache bash netcat-openbsd sudo - RUN mkdir -p /opt/zoraxy/source/ &&\ mkdir -p /opt/zoraxy/config/ &&\ mkdir -p /usr/local/bin/ @@ -17,23 +15,18 @@ RUN go mod tidy &&\ go build -o /usr/local/bin/zoraxy &&\ rm -r /opt/zoraxy/source/ +RUN chmod 755 /usr/local/bin/zoraxy &&\ + chmod +x /usr/local/bin/zoraxy + FROM docker.io/alpine:3.20 RUN apk add --no-cache bash netcat-openbsd sudo -RUN mkdir -p /opt/zoraxy/source/ &&\ - mkdir -p /opt/zoraxy/config/ &&\ - mkdir -p /usr/local/bin/ +COPY --from=build /usr/local/bin/zoraxy /usr/local/bin/zoraxy +COPY --from=build /opt/zoraxy/config/ /opt/zoraxy/config VOLUME [ "/opt/zoraxy/config/" ] -RUN chmod -R 770 /opt/zoraxy/ - -COPY --from=build /usr/local/bin/zoraxy /usr/local/bin/zoraxy - -RUN chmod 755 /usr/local/bin/zoraxy &&\ - chmod +x /usr/local/bin/zoraxy - WORKDIR /opt/zoraxy/config/ ENV AUTORENEW="86400" @@ -52,4 +45,4 @@ ENV ZTPORT="9993" ENTRYPOINT "zoraxy" "-docker=true" "-autorenew=${AUTORENEW}" "-fastgeoip=${FASTGEOIP}" "-log=${LOG}" "-mdns=${MDNS}" "-mdnsname=${MDNSNAME}" "-noauth=${NOAUTH}" "-port=:${PORT}" "-sshlb=${SSHLB}" "-version=${VERSION}" "-webfm=${WEBFM}" "-webroot=${WEBROOT}" "-ztauth=${ZTAUTH}" "-ztport=${ZTPORT}" -HEALTHCHECK --interval=15s --timeout=5s --start-period=10s --retries=3 CMD nc -vz 127.0.0.1 $PORT || exit 1 \ No newline at end of file +HEALTHCHECK --interval=15s --timeout=5s --start-period=10s --retries=3 CMD nc -vz 127.0.0.1 $PORT || exit 1