From 6330e844bcdb2c7da567329eadfaa6e5daf12e78 Mon Sep 17 00:00:00 2001 From: Karl Breuer Date: Mon, 24 Mar 2025 14:44:59 +0100 Subject: [PATCH] initial --- .dockerignore | 0 .gitignore | 3 ++ Dockerfile | 19 ++++++++++++ README.md | 62 ++++++++++++++++++++++++++++++++++++++++ docker-compose.yml | 10 +++++++ example.env | 5 ++++ go.mod | 9 ++++++ go.sum | 6 ++++ main.go | 9 ++++++ pkg/settings/settings.go | 25 ++++++++++++++++ servego4lage.sh | 5 ++++ 11 files changed, 153 insertions(+) create mode 100644 .dockerignore create mode 100644 .gitignore create mode 100644 Dockerfile create mode 100644 README.md create mode 100644 docker-compose.yml create mode 100644 example.env create mode 100644 go.mod create mode 100644 go.sum create mode 100644 main.go create mode 100644 pkg/settings/settings.go create mode 100644 servego4lage.sh diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..e69de29 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1d6812e --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.env +deploy.sh +palanticshelper \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..6228b61 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,19 @@ +# syntax=docker/dockerfile:1 +FROM golang:1.24 + +WORKDIR /app + +ENV PATH="/go/bin:${PATH}" + +COPY go.mod go.sum ./ +RUN go mod download + +COPY . . + +# Explicitly copy and set permissions for servego4lage.sh +COPY servego4lage.sh /app/servego4lage.sh +RUN chmod +x /app/servego4lage.sh + +WORKDIR /app + +ENTRYPOINT ["/app/servego4lage.sh"] diff --git a/README.md b/README.md new file mode 100644 index 0000000..6323a9f --- /dev/null +++ b/README.md @@ -0,0 +1,62 @@ +# Palantics Tracker Helper + +A tool that counters anti-tracking measures by removing third-party requests. Your server will do the requests instead. + +This is the recommended way to setup palantics. But only using the frontend script with the tracker server directly does work as well :) + +## Installation + +### 1. Copy or clone this repo to your server + +```bash +cp example.env .env +``` + +Edit your `.env` file and make sure you use the correct tracking server. + +```bash +docker-compose up -d +``` + +### 2. Update your Reverse Proxy config + +Configure your reverse proxy to catch requests and forward them to Palantics Helper. + +Remember to set the PORT correctly to match your .env PORT. + +#### NGINX: + +```nginx +location /spur { + proxy_pass http://127.0.0.1:8101; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; +} +``` + +#### Traefik: + +```yaml +# Traefik configuration +labels: + - "traefik.enable=true" + - "traefik.http.routers.palantics.rule=Host(`yourdomain.com`) && PathPrefix(`/spur`)" + - "traefik.http.routers.palantics.entrypoints=web,websecure" + - "traefik.http.routers.palantics.tls=true" + - "traefik.http.services.palantics.loadbalancer.server.port=8101" +``` + +### 3. Update Global Server Config + +In the global server config in your frontend, replace the tracker endpoint with your own domain: + +```html + + +``` + +INSTEAD of your tracker endpoint `https://tracking1.karlbreuer.com` \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..a9145d6 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,10 @@ +services: + app: + env_file: ".env" + build: . + ports: + - "${PORT}:${PORT}" + volumes: + - ./.env:/app/.env + container_name: "${APP_NAME}_app" + restart: unless-stopped \ No newline at end of file diff --git a/example.env b/example.env new file mode 100644 index 0000000..7212ec7 --- /dev/null +++ b/example.env @@ -0,0 +1,5 @@ +PORT=8101 #The Port of this app. just use a free port. Make this consistent with your Nginx or Traeffik config. +DOMAIN=karlbreuer.com #This should be your domain. +DEBUG=TRUE #Debug mode. FALSE in Prod +TRACKINGSERVERURL=tracking1.karlbreuer.com # The palantics tracking server. Provided by palantics. +APP_NAME=palanticshelper \ No newline at end of file diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..5b48d73 --- /dev/null +++ b/go.mod @@ -0,0 +1,9 @@ +module gitea.karlbreuer.com/karl/palanticshelper + +go 1.24.0 + +require ( + github.com/DeanPDX/dotconfig v1.0.0 + github.com/go-chi/chi v1.5.5 + github.com/go-chi/cors v1.2.1 +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..4565779 --- /dev/null +++ b/go.sum @@ -0,0 +1,6 @@ +github.com/DeanPDX/dotconfig v1.0.0 h1:hVBXe96OcU4YHqropy4zpKvcU6qc7PmTpsDBrUj5Lu0= +github.com/DeanPDX/dotconfig v1.0.0/go.mod h1:18zbUTCrXlYeQqJmrtjBVtNFTUPEfqTzdrf8dh1kHNc= +github.com/go-chi/chi v1.5.5 h1:vOB/HbEMt9QqBqErz07QehcOKHaWFtuj87tTDVz2qXE= +github.com/go-chi/chi v1.5.5/go.mod h1:C9JqLr3tIYjDOZpzn+BCuxY8z8vmca43EeMgyZt7irw= +github.com/go-chi/cors v1.2.1 h1:xEC8UT3Rlp2QuWNEr4Fs/c2EAGVKBwy/1vHx3bppil4= +github.com/go-chi/cors v1.2.1/go.mod h1:sSbTewc+6wYHBBCW7ytsFSn836hqM7JxpglAy2Vzc58= diff --git a/main.go b/main.go new file mode 100644 index 0000000..4dfde16 --- /dev/null +++ b/main.go @@ -0,0 +1,9 @@ +package main + +import ( + "gitea.karlbreuer.com/karl/palanticshelper/pkg/palanticshelper" +) + +func main() { + palanticshelper.StartServer() +} diff --git a/pkg/settings/settings.go b/pkg/settings/settings.go new file mode 100644 index 0000000..773f0ce --- /dev/null +++ b/pkg/settings/settings.go @@ -0,0 +1,25 @@ +package settings + +import ( + "fmt" + + "github.com/DeanPDX/dotconfig" +) + +var Settings PhelperSettings + +type PhelperSettings struct { + Domain string `env:"DOMAIN"` + TrackingServerURL string `env:"TRACKINGSERVERURL"` + Debug bool `env:"DEBUG"` + Port string `env:"PORT"` +} + +func init() { + + var err error + Settings, err = dotconfig.FromFileName[PhelperSettings](".env") + if err != nil { + fmt.Printf("Error: %v.", err) + } +} diff --git a/servego4lage.sh b/servego4lage.sh new file mode 100644 index 0000000..a716766 --- /dev/null +++ b/servego4lage.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +set -e +go build -o palantics +./palantics +