Skip to content
This repository has been archived by the owner on Jul 3, 2024. It is now read-only.

Commit

Permalink
add source code from local folder
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonPrinz committed Dec 5, 2020
1 parent 26658f7 commit 254f3a0
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 1 deletion.
6 changes: 6 additions & 0 deletions Caddyfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
:80 {
reverse_proxy {
to HOSTS
lb_policy round_robin
}
}
7 changes: 7 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM caddy:2-alpine
WORKDIR /app

COPY Caddyfile .
COPY generateCaddyfile.sh .

CMD ["./generateCaddyfile.sh"]
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,12 @@
# CaddyBalancer
A Docker image for load balancing based on Caddy

A Docker image for load balancing based on Caddy

## Usage

```bash
docker run -d \
-p 8080:80 \
-e UPSTREAMS="http://12.34.56.78:9999,http://98.76.54.32:1111" \
docker.pkg.github.com/simonprinz/caddybalancer/caddybalancer:latest
```
9 changes: 9 additions & 0 deletions generateCaddyfile.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh

# generate Caddyfile
hosts=`echo "$UPSTREAMS" | sed "s|,|\\\\\\n\\t\\tto |"`
sed -i "s|HOSTS|$hosts|" Caddyfile
cat Caddyfile

# run caddy
caddy run --config /app/Caddyfile --adapter caddyfile

0 comments on commit 254f3a0

Please sign in to comment.