From c41ef4ba8859dfeeba205ac23b1e5eedd627cd69 Mon Sep 17 00:00:00 2001 From: JMARyA Date: Fri, 30 Aug 2024 13:28:33 +0200 Subject: [PATCH] init --- Dockerfile | 18 ++++++++++++++++++ README.md | 16 ++++++++++++++++ docker-compose.yml | 10 ++++++++++ entrypoint.sh | 5 +++++ 4 files changed, 49 insertions(+) create mode 100644 Dockerfile create mode 100644 README.md create mode 100644 docker-compose.yml create mode 100644 entrypoint.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..1742e6a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,18 @@ +FROM alpine:latest AS builder + +RUN apk update && apk upgrade && \ + apk add --no-cache go git + +WORKDIR / +RUN git clone "https://github.com/jpillora/chisel" +WORKDIR /chisel +RUN go build -o chisel main.go + +FROM alpine:latest + +RUN apk update && apk upgrade && \ + apk add --no-cache socat bash + +COPY --from=builder /chisel/chisel /usr/bin/chisel +COPY ./entrypoint.sh /entrypoint.sh +CMD ["/bin/bash", "/entrypoint.sh"] diff --git a/README.md b/README.md new file mode 100644 index 0000000..17976d0 --- /dev/null +++ b/README.md @@ -0,0 +1,16 @@ +# Chisel Forward +This container allows to forward a local port to a remote system running chisel server. + +# TODO +- Load Balancing +- Error Handling +- UDP + +## Configuration +The container is configured through environment variables: +- `$HOST`: The host running chisel server +- `$LOCAL_PORT`: The local port to forward +- `$LOCAL_HOST`: The local host address +- `$REMOTE_PORT`: The remote port to expose the forward on +- `$USER`: Authentication User +- `$TOKEN`: Authentication Token diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..c57a5fd --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,10 @@ +services: + forward: + build: . + restart: unless-stopped + environment: + HOST: "https://chisel.example.com" + LOCAL_PORT: "8080" + REMOTE_PORT: "8080" + USER: "user" + TOKEN: "token" diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..bf81fd2 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +socat TCP4-LISTEN:$LOCAL_PORT,fork,reuseaddr TCP4:TCP4:$LOCAL_HOST:$LOCAL_PORT & +chisel client --auth "$USER:$TOKEN" "$HOST" "R:$LOCAL_HOST:$LOCAL_PORT:127.0.0.1:$REMOTE_PORT" & +wait