1. Caddy version (caddy version
):
v2.4.2
2. How I run Caddy:
caddy run -config /etc/Caddyfile
a. System environment:
Docker container (ubuntu:18.04) with supervisord
b. Command:
caddy run -config /etc/Caddyfile
c. Service/unit/compose file:
# get the caddy executable
FROM caddy AS caddy-build
FROM ubuntu:18.04
# install geth, python, node, and smart contract development tooling
RUN apt update -y \
&& apt install -y software-properties-common gpg \
&& add-apt-repository -y ppa:deadsnakes/ppa \
&& add-apt-repository -y ppa:ethereum/ethereum \
&& apt update -y \
&& apt install -y \
ethereum solc \
supervisor \
python3.8 python3-pip python3.8-dev \
vim curl tmux git zip unzip vim speedometer net-tools \
&& python3.8 -m pip install web3 py-solc py-solc-x \
&& curl -fsSL https://deb.nodesource.com/setup_12.x | bash - \
&& apt install -y nodejs \
&& npm install -g solc \
&& curl https://rclone.org/install.sh | bash \
&& rm -rf /var/lib/apt/lists/*
# get the Caddy server executable
# copy the caddy server build into this container
COPY --from=caddy-build /usr/bin/caddy /usr/bin/caddy
COPY Caddyfile /etc/
RUN chmod a+rwx /etc/Caddyfile
ENTRYPOINT ["sh", "-c", "supervisord"]
d. My complete Caddyfile or JSON config:
:8888 {
log
root * /home/user1
redir / /ui/
handle_path /ui/* {
reverse_proxy http://localhost:3000
import /tmp/hashpass.txt
}
handle_path /http/* {
reverse_proxy http://127.0.0.1:8545
health_uri /ok
}
handle_path /ws/* {
reverse_proxy ws://127.0.0.1:8546
}
}
3. The problem I’m having:
I’m new to caddy and running my own server for that matter, but i’ve been using caddy for a couple of months now and I really like how easy it is to use. I’m using caddy as a reverse proxy for a geth node and it works great, but I would like to use caddy’s built in health check capability to monitor the geth process. I’m looking for a way to leverage caddy’s built-in capabilities to automatically post a string to a local service/port if my geth node becomes unhealthy.
So my question is, is it possible to do this someway with caddy’s active heath check directives? Thank you Caddy community for the great software.
4. Error messages and/or full log output:
5. What I already tried:
I currently use a bash script to detect if the service running on localhost:8545
is still healthy and have it post via a simple curl command when the service is unavailable. But since it’s so easy to define a health check in caddy, I though I’d see if I could accomplish the same thing with caddy’s utilities.