diff --git a/docker-compose.yml b/docker-compose.yml index 7b72d86..6e5767e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,5 +1,12 @@ version: "3.6" services: + # Proxy to forward legacy requests to beacon-validator instead of beacon-chain or validator + beacon-validator: + build: + context: proxy + depends_on: + - beacon-chain + - validator beacon-chain: build: diff --git a/package_variants/gnosis/docker-compose.yml b/package_variants/gnosis/docker-compose.yml index ca6b6df..cdbabe3 100644 --- a/package_variants/gnosis/docker-compose.yml +++ b/package_variants/gnosis/docker-compose.yml @@ -1,5 +1,10 @@ version: "3.5" services: + beacon-validator: + build: + args: + NETWORK: gnosis + beacon-chain: build: args: diff --git a/package_variants/holesky/docker-compose.yml b/package_variants/holesky/docker-compose.yml index adebb45..c30fdc2 100644 --- a/package_variants/holesky/docker-compose.yml +++ b/package_variants/holesky/docker-compose.yml @@ -1,5 +1,10 @@ version: "3.5" services: + beacon-validator: + build: + args: + NETWORK: holesky + beacon-chain: build: args: diff --git a/package_variants/mainnet/docker-compose.yml b/package_variants/mainnet/docker-compose.yml index e850f47..7611443 100644 --- a/package_variants/mainnet/docker-compose.yml +++ b/package_variants/mainnet/docker-compose.yml @@ -1,5 +1,10 @@ version: "3.5" services: + beacon-validator: + build: + args: + NETWORK: mainnet + beacon-chain: build: args: diff --git a/proxy/Dockerfile b/proxy/Dockerfile new file mode 100644 index 0000000..3d87812 --- /dev/null +++ b/proxy/Dockerfile @@ -0,0 +1,15 @@ +FROM nginx:1.27.0-alpine + +ARG NETWORK + +ENV NETWORK=${NETWORK} + +COPY nginx.conf /etc/nginx/nginx.conf.template + +COPY entrypoint.sh /usr/local/bin/entrypoint.sh + +RUN chmod +x /usr/local/bin/entrypoint.sh + +ENTRYPOINT ["/usr/local/bin/entrypoint.sh"] + +CMD ["nginx", "-g", "daemon off;"] diff --git a/proxy/entrypoint.sh b/proxy/entrypoint.sh new file mode 100755 index 0000000..aa5c827 --- /dev/null +++ b/proxy/entrypoint.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +if [ -z "${NETWORK}" ]; then + echo "NETWORK is not defined. Exiting." + exit 1 +fi + +if [ "${NETWORK}" = "mainnet" ]; then + BEACON_CHAIN_URL="http://beacon-chain.nimbus.dappnode:3500" + VALIDATOR_URL="http://validator.nimbus.dappnode:3500" +else + BEACON_CHAIN_URL="http://beacon-chain.nimbus-${NETWORK}.dappnode:3500" + VALIDATOR_URL="http://validator.nimbus-${NETWORK}.dappnode:3500" +fi + +# Replace variables in nginx.conf +sed -e "s|\${VALIDATOR_URL}|${VALIDATOR_URL}|g" -e "s|\${BEACON_CHAIN_URL}|${BEACON_CHAIN_URL}|g" /etc/nginx/nginx.conf.template >/etc/nginx/nginx.conf + +# Start nginx +exec "$@" diff --git a/proxy/nginx.conf b/proxy/nginx.conf new file mode 100644 index 0000000..a23087e --- /dev/null +++ b/proxy/nginx.conf @@ -0,0 +1,27 @@ +events {} + +http { + server { + listen 3500; + + location / { + proxy_pass ${VALIDATOR_URL}; + 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; + } + } + + server { + listen 4500; + + location / { + proxy_pass ${BEACON_CHAIN_URL}; + 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; + } + } +}