Skip to content

Commit

Permalink
Merge pull request #4 from djerfy/feat/improvements
Browse files Browse the repository at this point in the history
feat: global improvements of OpenChia proxy
  • Loading branch information
william-gr authored Nov 20, 2023
2 parents 171d07e + d53d021 commit eeab81d
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 36 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.git
README.md
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM caddy:2.6.2-alpine
FROM caddy:2.7.4-alpine

# Identify the maintainer of an image
LABEL maintainer="[email protected]"
Expand All @@ -8,7 +8,7 @@ EXPOSE 443

RUN rm -rf /tmp/build

COPY ./Caddyfile /etc/
COPY ./entrypoint.sh /root/
COPY ./docker/caddy/Caddyfile /etc/Caddyfile.tpl
COPY ./docker/entrypoint.sh /

CMD ["sh", "/root/entrypoint.sh"]
CMD ["sh", "/entrypoint.sh"]
24 changes: 24 additions & 0 deletions Caddyfile → docker/caddy/Caddyfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@

reverse_proxy @spa %%WEB_HOSTNAME%%:80

log {
output stdout
format %%LOGFORMAT%%
level %%LOGLEVEL%%
}

}

%%REDIRECT_DOMAIN%% {
Expand All @@ -34,6 +40,12 @@

redir https://%%WWW_DOMAIN%%{uri}

log {
output stdout
format %%LOGFORMAT%%
level %%LOGLEVEL%%
}

}

%%POOL_DOMAIN%% {
Expand All @@ -44,6 +56,12 @@
trusted_proxies private_ranges %%TRUSTED_PROXIES%%
}

log {
output stdout
format %%LOGFORMAT%%
level %%LOGLEVEL%%
}

}


Expand All @@ -55,5 +73,11 @@
trusted_proxies private_ranges
}

log {
output stdout
format %%LOGFORMAT%%
level %%LOGLEVEL%%
}

}
%%POOL2_DOMAIN_END%%
40 changes: 40 additions & 0 deletions docker/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/sh
set -x

if [ ! -e "/etc/Caddyfile" ]; then
if [ -z "${CERTBOT_EMAIL}" ]; then
echo "CERTBOT_EMAIL required"
exit 1
fi

if [ -n "${TLS_CERT}" -a -n "${TLS_KEY}" ]; then
sed -i "s,%%TLS%%,tls ${TLS_CERT} ${TLS_KEY},g" /etc/Caddyfile.tpl
else
sed -i s,%%TLS%%,,g /etc/Caddyfile.tpl
fi

sed -i s,%%EMAIL%%,${CERTBOT_EMAIL},g /etc/Caddyfile.tpl
sed -i s,%%WWW_DOMAIN%%,${WWW_DOMAIN:=localhost},g /etc/Caddyfile.tpl
sed -i s,%%POOL_DOMAIN%%,${POOL_DOMAIN:=pool},g /etc/Caddyfile.tpl
sed -i s,%%REDIRECT_DOMAIN%%,${REDIRECT_DOMAIN:=www},g /etc/Caddyfile.tpl
sed -i s,%%API_HOSTNAME%%,${API_HOSTNAME:=api},g /etc/Caddyfile.tpl
sed -i s,%%POOL_HOSTNAME%%,${POOL_HOSTNAME:=pool},g /etc/Caddyfile.tpl
sed -i s,%%WEB_HOSTNAME%%,${WEB_HOSTNAME:=web},g /etc/Caddyfile.tpl
sed -i s,%%TRUSTED_PROXIES%%,${TRUSTED_PROXIES},g /etc/Caddyfile.tpl
sed -i s,%%LOGFORMAT,${LOGFORMAT:=json},g /etc/Caddyfile.tpl
sed -i s,%%LOGLEVEL%%,${LOGLEVEL:=INFO},g /etc/Caddyfile.tpl

# Allow a second pool domain
if [ -n "${POOL2_DOMAIN}" ]; then
sed -i s,%%POOL2_DOMAIN%%,${POOL2_DOMAIN},g /etc/Caddyfile.tpl
sed -i s,%%POOL2_DOMAIN_END%%,,g /etc/Caddyfile.tpl
else
sed -i '/%%POOL2_DOMAIN%%/,/%%POOL2_DOMAIN_END%%/c' /etc/Caddyfile.tpl
fi

mv /etc/Caddyfile.tpl /etc/Caddyfile
else
rm -f /etc/Caddyfile.tpl
fi

exec caddy run --config /etc/Caddyfile
32 changes: 0 additions & 32 deletions entrypoint.sh

This file was deleted.

0 comments on commit eeab81d

Please sign in to comment.