Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update caddy to 2.8 #70

Merged
merged 3 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ jobs:
- name: build caddy - xcaddy build
run: >
xcaddy build
--with github.com/hairyhenderson/[email protected]
--with github.com/caddyserver/forwardproxy@caddy2
--output proxy/caddy
- name: validate Caddyfile
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# See "Adding custom Caddy modules" here:
# https://hub.docker.com/_/caddy

FROM caddy:2.7-builder AS builder
FROM caddy:2.8-builder AS builder

ARG GOARCH=amd64
RUN xcaddy build \
--with github.com/caddyserver/forwardproxy@caddy2

FROM caddy:2.7-alpine
FROM caddy:2.8-alpine

RUN apk update
RUN apk upgrade
Expand Down
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Build the caddy binary and copy it into the proxy subdirectory
caddy-v2-with-forwardproxy: Dockerfile proxy/Caddyfile
docker compose build
docker compose up -d
docker compose cp caddy:/usr/bin/caddy proxy/caddy
docker compose up -d
- docker compose cp caddy:/usr/bin/caddy proxy/caddy
docker compose down

validate:
echo "test.gov" > allow.acl
echo "test.com" > deny.acl
sed -i 's/tls cert.pem key.pem/# tls cert.pem key.pem/g' proxy/Caddyfile
sed -i.bak 's/tls cert.pem key.pem/# tls cert.pem key.pem/g' proxy/Caddyfile && rm proxy/Caddyfile.bak
rahearn marked this conversation as resolved.
Show resolved Hide resolved
PORT=9999 PROXY_USERNAME=admin PROXY_PASSWORD=pass PROXY_PORTS=443 ./proxy/caddy validate --config proxy/Caddyfile
sed -i 's/# tls cert.pem key.pem/tls cert.pem key.pem/g' proxy/Caddyfile
rm allow.acl deny.acl
sed -i.bak 's/# tls cert.pem key.pem/tls cert.pem key.pem/g' proxy/Caddyfile
rm proxy/Caddyfile.bak allow.acl deny.acl
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here... Why create a .bak file if we have no intention of leaving it around?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because sed -i 's... doesn't work on macos (-i requires an argument) and the internet says that while sed -i '' will work on macos it will break on linux. The only fully cross-platform way is to create the backup file and then remove it

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahhhh, so that's the M1-specific update you made... I was wondering.

Do you want to leave a comment to that effect, with a reference? That will stop ignorant folks like me from removing it in future updates.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would it make more sense to just install gnu-sed with homebrew?

https://daoyuan.li/a-normal-sed-on-mac/

4 changes: 1 addition & 3 deletions docker-compose.yml → compose.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
---
version: "3.7"

services:
caddy:
build:
Expand All @@ -22,6 +19,7 @@ services:
# The variables that matter to the app
- PROXY_USERNAME=user
- PROXY_PASSWORD=pass
- PROXY_PORTS=443
- PROXY_DENY="*.yahoo.com"
- PROXY_ALLOW= |
"*.google.com
Binary file modified proxy/caddy
Binary file not shown.
Loading