Skip to content

Commit

Permalink
Add beacon-validator proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
dappnodedev committed Jul 5, 2024
1 parent 910a977 commit 5d58fa6
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 0 deletions.
7 changes: 7 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
5 changes: 5 additions & 0 deletions package_variants/gnosis/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
version: "3.5"
services:
beacon-validator:
build:
args:
NETWORK: gnosis

beacon-chain:
build:
args:
Expand Down
5 changes: 5 additions & 0 deletions package_variants/holesky/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
version: "3.5"
services:
beacon-validator:
build:
args:
NETWORK: holesky

beacon-chain:
build:
args:
Expand Down
5 changes: 5 additions & 0 deletions package_variants/mainnet/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
version: "3.5"
services:
beacon-validator:
build:
args:
NETWORK: mainnet

beacon-chain:
build:
args:
Expand Down
15 changes: 15 additions & 0 deletions proxy/Dockerfile
Original file line number Diff line number Diff line change
@@ -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;"]
20 changes: 20 additions & 0 deletions proxy/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -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 "$@"
27 changes: 27 additions & 0 deletions proxy/nginx.conf
Original file line number Diff line number Diff line change
@@ -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;
}
}
}

0 comments on commit 5d58fa6

Please sign in to comment.