Sign inSign up

vaayne/naiveproxy

By vaayne

•Updated about 3 years ago

Image
0

431

vaayne/naiveproxy repository overview

⁠Dockerfile

FROM golang:1.20 as build

WORKDIR /go/src/app

RUN go install github.com/caddyserver/xcaddy/cmd/xcaddy@latest && \
    /go/bin/xcaddy build --with github.com/caddyserver/forwardproxy@caddy2=github.com/klzgrad/forwardproxy@naive


FROM gcr.io/distroless/base-debian11
WORKDIR /app/

COPY --from=build /go/src/app/caddy .

ENTRYPOINT ["/app/caddy"]

⁠Build

⁠docker-bake.hcl
group "default" {
  targets = ["naiveproxy"]
}

target "naiveproxy" {
  dockerfile = "Dockerfile"
  platforms = ["linux/amd64", "linux/arm64"]
  tags = ["vaayne/naiveproxy:latest"]
}
⁠Build command

docker buildx bake -f docker-bake.hcl --push

⁠Usage

⁠Example Caddy config Caddyfile
{
	order forward_proxy before reverse_proxy
	log default {
		level INFO
		output stdout
		format console
	}
}
:443, $DOMAIN {
	tls $EMAIL
	forward_proxy {
		basic_auth $NV_USER $NV_PASS
		hide_ip
		hide_via
		probe_resistance
	}
	reverse_proxy https://hn.algolia.com {
		header_up Host {upstream_hostport}
	}
}

⁠Useful script

#!/bin/bash

set -euo pipefail

CADDY_DIR="$HOME/caddy"

run() {
    docker run \
        --name naiveproxy \
        -d \
        --net host \
        -e XDG_DATA_HOME=/data \
        -v "$CADDY_DIR":/data \
        vaayne/naiveproxy:latest \
        run -c /data/Caddyfile
}

fmt() {
    docker run --rm \
        -v "$CADDY_DIR":/data \
        vaayne/naiveproxy:latest \
        fmt /data/Caddyfile --overwrite
}

build() {
    docker buildx bake -f docker-bake.hcl --push
}

stop() {
    docker stop naiveproxy
}

restart() {
    docker restart naiveproxy
}

rerun() {
    docker rm -f naiveproxy
    run
}

# Function to display help information for the script
help() {
    echo "Usage: $0 [run|fmt|build|stop|restart|help]"
    echo "  run:    Start the Caddy server"
    echo "  fmt:    Format the Caddyfile"
    echo "  build:  Build the Caddy image"
    echo "  stop:   Stop the Caddy server"
    echo "  restart:Restart the Caddy server"
    echo "  rerun:  Recreate the Caddy server"
    echo "  help:   Display this help message"
}

case "$1" in
run) run ;;
fmt) fmt ;;
build) build ;;
stop) stop ;;
restart) restart ;;
*) help ;;
esac


Tag summary

Content type

Image

Digest

sha256:d50168e3c…

Size

23.6 MB

Last updated

about 3 years ago

docker pull vaayne/naiveproxy