Testnet & Mainnet support out of the box

This commit is contained in:
Wietse Wind
2023-10-29 01:40:26 +02:00
parent 2a733dbd5d
commit 149bba85bd
3 changed files with 213 additions and 25 deletions

View File

@@ -37,19 +37,25 @@ http {
default 0;
}
upstream backend {
server xpop:3000;
upstream backend-testnet {
server xpop-testnet:3000;
keepalive 32;
}
upstream backend-mainnet {
server xpop-mainnet:3000;
keepalive 32;
}
# TESTNET
server {
# The config below is for http (non SSL)
listen 3000;
listen [::]:3000;
listen $PUBLIC_PORT_TESTNET;
listen [::]:$PUBLIC_PORT_TESTNET;
# The config below is for SSL (https)
listen 3443 ssl;
listen [::]:3443 ssl;
listen $SSLPORT_TESTNET ssl;
listen [::]:$SSLPORT_TESTNET ssl;
ssl_session_timeout 5m;
ssl_ciphers ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:RSA+AES:!ADH:!AECDH:!MD5:!DSS;
@@ -107,7 +113,7 @@ http {
}
location / {
proxy_pass http://backend;
proxy_pass http://backend-testnet;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
@@ -120,14 +126,86 @@ http {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-No-Cors 1;
}
} # END: server {}
# error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
# error_page 500 502 503 504 /50x.html;
# location = /50x.html {
# root /usr/share/nginx/html;
# }
# MAINNET
server {
# The config below is for http (non SSL)
listen $PUBLIC_PORT;
listen [::]:$PUBLIC_PORT;
# The config below is for SSL (https)
listen $SSLPORT ssl;
listen [::]:$SSLPORT ssl;
ssl_session_timeout 5m;
ssl_ciphers ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:RSA+AES:!ADH:!AECDH:!MD5:!DSS;
ssl_protocols TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;
resolver 1.1.1.1 8.8.8.8 [2606:4700::1111] [2606:4700:4700::1001] valid=300s ipv6=on;
resolver_timeout 5s;
ssl_stapling on;
ssl_stapling_verify on;
add_header Strict-Transport-Security "max-age=31536000; includeSubdomains;";
ssl_certificate_key /etc/nginx/ssl/nginx-ssl-private.key;
ssl_certificate /etc/nginx/ssl/nginx-ssl-certificate.pem;
ssl_dhparam /etc/nginx/ssl/dhparam.pem;
# Regular config
server_name _;
autoindex_format html;
add_header Access-Control-Allow-Origin *;
try_files $uri $uri/ =404;
absolute_redirect off;
location /healthcheck {
return 200 'Hi there!';
add_header Content-Type text/plain;
}
location /xpop {
root /usr/share/nginx/html;
autoindex off;
}
if ($http_content_type ~* json) {
set $json_request 1;
}
location ~ ^/json(/.*)?$ {
internal;
alias /usr/share/nginx/html$1; # Point to the same root as the previous location
autoindex on;
autoindex_format json;
}
location ~* ^/[0-9]+ {
root /usr/share/nginx/html;
autoindex on;
if ($is_json_request = 1) {
rewrite ^ /json$request_uri? last;
}
}
location / {
proxy_pass http://backend-mainnet;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_cache off;
proxy_buffering off;
# Configuration for LongPolling or if your KeepAliveInterval is longer than 60 seconds
proxy_read_timeout 100s;
proxy_set_header Host $host;
proxy_set_header X-Incoming-Scheme $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-No-Cors 1;
}
} # END: server {}
}

View File

@@ -0,0 +1,75 @@
version: '3.4'
services:
nginx:
container_name: xpopweb-${NAME:-default}
read_only: true
volumes:
- ./conf/nginx.conf:/etc/nginx/nginx.conf:ro
- ./conf/ssl:/etc/nginx/ssl:ro
- nginxcache:/var/cache/nginx
- nginxpid:/var/run
- ./store/:/usr/share/nginx/html:ro
ports:
- ${PORT:-3000}:3000
- ${SSLPORT:-3443}:3443
image: nginx:alpine
restart: unless-stopped
healthcheck:
test: curl --fail http://localhost:3000/healthcheck || exit 1
interval: 15s
retries: 2
start_period: 5s
timeout: 5s
xpop:
container_name: xpop-${NAME:-default}
image: xpop:service
build: .
volumes:
- ./store:/usr/src/app/store
environment:
- EVENT_SOCKET_PORT=3000
- PUBLIC_PORT=${PORT:-3000}
- URL_PREFIX=${URL_PREFIX:-http://localhost:3000}
- NETWORKID=${NETWORKID:-1}
- UNLURL=${UNLURL:-https://vl.altnet.rippletest.net}
- UNLKEY=${UNLKEY:-ED264807102805220DA0F312E71FC2C69E1552C9C5790F6C25E3729DEB573D5860}
- NODES=${NODES:-wss://testnet.xrpl-labs.com,wss://s.altnet.rippletest.net:51233}
- FIELDSREQUIRED=${FIELDSREQUIRED:-Fee,Account,OperationLimit}
- NOVALIDATIONLOG=${NOVALIDATIONLOG}
- NOELIGIBLEFULLTXLOG=${NOELIGIBLEFULLTXLOG}
- ONLYUNLVALIDATIONS=${ONLYUNLVALIDATIONS}
- DEBUG=${DEBUG}
- TELEMETRY=${TELEMETRY:-NO}
restart: unless-stopped
healthcheck:
test: wget --spider -q http://localhost:3000/health || exit 1
interval: 15s
retries: 2
start_period: 5s
timeout: 5s
xpopcleaner:
container_name: xpopcleaner-${NAME:-default}
image: alpine
entrypoint: sh -c "TTL_MINUTES_PREGEN_XPOP=${TTL_MINUTES_PREGEN_XPOP:-60} TTL_DAYS_XPOP_SOURCE_FILES=${TTL_DAYS_XPOP_SOURCE_FILES:-30} sh /cleanup.sh && tail -f /dev/null"
stop_grace_period: 0s
volumes:
- ./store:/store
- ./scripts/cleanup.sh:/cleanup.sh
restart: unless-stopped
healthcheck:
test: TTL_MINUTES_PREGEN_XPOP=${TTL_MINUTES_PREGEN_XPOP:-60} TTL_DAYS_XPOP_SOURCE_FILES=${TTL_DAYS_XPOP_SOURCE_FILES:-30} sh /cleanup.sh
interval: ${TTL_MINUTES_CLEANUP_INTERVAL:-60}m
retries: 10
timeout: 55m
volumes:
nginxcache:
nginxpid:
networks:
default:
enable_ipv6: true
ipam:
driver: default
config:
- subnet: 172.28.0.0/16
- subnet: "fd00:dead:beef::/48"

View File

@@ -4,7 +4,7 @@ services:
container_name: xpopweb
read_only: true
volumes:
- ./conf/nginx.conf:/etc/nginx/nginx.conf:ro
- ./conf/nginx.conf:/etc/nginx/nginx.conf.template:ro
- ./conf/ssl:/etc/nginx/ssl:ro
- nginxcache:/var/cache/nginx
- nginxpid:/var/run
@@ -12,7 +12,14 @@ services:
ports:
- ${PORT:-3000}:3000
- ${SSLPORT:-3443}:3443
- ${PORT_TESTNET:-3001}:3001
- ${SSLPORT_TESTNET:-3444}:3444
image: nginx:alpine
environment:
- PUBLIC_PORT=${PORT:-3000}
- PUBLIC_PORT_TESTNET=${PORT_TESTNET:-3001}
- SSLPORT=${SSLPORT:-3443}
- SSLPORT_TESTNET=${SSLPORT_TESTNET:-3444}
restart: unless-stopped
healthcheck:
test: curl --fail http://localhost:3000/healthcheck || exit 1
@@ -20,8 +27,36 @@ services:
retries: 2
start_period: 5s
timeout: 5s
xpop:
container_name: xpop
command: /bin/sh -c "envsubst '$$PUBLIC_PORT $$PUBLIC_PORT_TESTNET $$SSLPORT $$SSLPORT_TESTNET' < /etc/nginx/nginx.conf.template > /var/cache/nginx/conf ; nginx -c /var/cache/nginx/conf -g 'daemon off;'"
xpop-testnet:
container_name: xpop-testnet
image: xpop:service
build: .
volumes:
- ./store:/usr/src/app/store
environment:
- EVENT_SOCKET_PORT=3000
- PUBLIC_PORT=${PORT_TESTNET:-3001}
- URL_PREFIX=${URL_PREFIX:-http://localhost:${PORT_TESTNET:-3001}}
- NETWORKID=1
- UNLURL=https://vl.altnet.rippletest.net
- UNLKEY=ED264807102805220DA0F312E71FC2C69E1552C9C5790F6C25E3729DEB573D5860
- NODES=wss://testnet.xrpl-labs.com,wss://s.altnet.rippletest.net:51233
- FIELDSREQUIRED=Fee,Account,OperationLimit
- NOVALIDATIONLOG=1
- NOELIGIBLEFULLTXLOG=1
- ONLYUNLVALIDATIONS=${ONLYUNLVALIDATIONS}
- DEBUG=${DEBUG}
- TELEMETRY=${TELEMETRY:-NO}
restart: unless-stopped
healthcheck:
test: wget --spider -q http://localhost:3000/health || exit 1
interval: 15s
retries: 2
start_period: 5s
timeout: 5s
xpop-mainnet:
container_name: xpop-mainnet
image: xpop:service
build: .
volumes:
@@ -29,14 +64,14 @@ services:
environment:
- EVENT_SOCKET_PORT=3000
- PUBLIC_PORT=${PORT:-3000}
- URL_PREFIX=${URL_PREFIX:-http://localhost:3000}
- NETWORKID=${NETWORKID:-1}
- UNLURL=${UNLURL:-https://vl.altnet.rippletest.net}
- UNLKEY=${UNLKEY:-ED264807102805220DA0F312E71FC2C69E1552C9C5790F6C25E3729DEB573D5860}
- NODES=${NODES:-wss://testnet.xrpl-labs.com,wss://s.altnet.rippletest.net:51233}
- FIELDSREQUIRED=${FIELDSREQUIRED:-Fee,Account,OperationLimit}
- NOVALIDATIONLOG=${NOVALIDATIONLOG}
- NOELIGIBLEFULLTXLOG=${NOELIGIBLEFULLTXLOG}
- URL_PREFIX=${URL_PREFIX:-http://localhost:${PORT:-3000}}
- NETWORKID=0
- UNLURL=https://vl.xrplf.org
- UNLKEY=ED45D1840EE724BE327ABE9146503D5848EFD5F38B6D5FEDE71E80ACCE5E6E738B
- NODES=wss://xrplcluster.com,wss://s2.ripple.com
- FIELDSREQUIRED=Fee,Account,OperationLimit
- NOVALIDATIONLOG=1
- NOELIGIBLEFULLTXLOG=1
- ONLYUNLVALIDATIONS=${ONLYUNLVALIDATIONS}
- DEBUG=${DEBUG}
- TELEMETRY=${TELEMETRY:-NO}