Allow external configure user defined origin that allows proper REST-API answer for browser originated requests

This commit is contained in:
NagyZoltanPeter 2024-03-14 13:26:18 +01:00
parent 6b3718586c
commit 3c223f1445
No known key found for this signature in database
GPG Key ID: 16EADB9673B65368
4 changed files with 9 additions and 2 deletions

View File

@ -16,3 +16,4 @@ NODEKEY=
DOMAIN= DOMAIN=
EXTRA_ARGS= EXTRA_ARGS=
STORAGE_SIZE= STORAGE_SIZE=
ALLOW_ORIGIN=

View File

@ -15,6 +15,7 @@ There are multiple environment variables you can configure to modify behaviour o
* `EXTRA_ARGS` - this variable allows you to specify additional or overriding CLI option for the Waku node which will be appended to the `wakunode2` command. (e.g. `EXTRA_ARGS="--store=false --max-connections=3000`) * `EXTRA_ARGS` - this variable allows you to specify additional or overriding CLI option for the Waku node which will be appended to the `wakunode2` command. (e.g. `EXTRA_ARGS="--store=false --max-connections=3000`)
* `CERTS_DIR` - allows you to define a path where SSL certificates are/will be stored. It needs to follow the directory structure produced by Certbot in `/etc/letsencrypt` * `CERTS_DIR` - allows you to define a path where SSL certificates are/will be stored. It needs to follow the directory structure produced by Certbot in `/etc/letsencrypt`
* `STORATE_SIZE` - overrides the default allowed DB size of waku message storage service. Current default is 1GB. (e.g. `STORAGE_SIZE=2GB` or `STORAGE_SIZE=3500MB`) * `STORATE_SIZE` - overrides the default allowed DB size of waku message storage service. Current default is 1GB. (e.g. `STORAGE_SIZE=2GB` or `STORAGE_SIZE=3500MB`)
* `ALLOW_ORIGIN` - Can set the allowed origin site that is enabled to use waku node's REST-API from browser. Great if you are connecting to the node with REST-API from a browser based app. (e.g. `ALLOW_ORIGIN=example.com` or `ALLOW_ORIGIN=localhost:*`)
## Log monitoring and troubleshooting ## Log monitoring and troubleshooting

View File

@ -50,6 +50,7 @@ services:
ETH_CLIENT_ADDRESS: *eth_client_address ETH_CLIENT_ADDRESS: *eth_client_address
EXTRA_ARGS: ${EXTRA_ARGS} EXTRA_ARGS: ${EXTRA_ARGS}
STORAGE_SIZE: ${STORAGE_SIZE} STORAGE_SIZE: ${STORAGE_SIZE}
ALLOW_ORIGIN: ${ALLOW_ORIGIN}
<<: <<:
- *pg_env - *pg_env
- *rln_env - *rln_env

View File

@ -48,17 +48,20 @@ fi
RLN_RELAY_CRED_PATH=--rln-relay-cred-path=${RLN_RELAY_CRED_PATH:-/keystore/keystore.json} RLN_RELAY_CRED_PATH=--rln-relay-cred-path=${RLN_RELAY_CRED_PATH:-/keystore/keystore.json}
if [ -n "${RLN_RELAY_CRED_PASSWORD}" ]; then if [ -n "${RLN_RELAY_CRED_PASSWORD}" ]; then
RLN_RELAY_CRED_PASSWORD=--rln-relay-cred-password="${RLN_RELAY_CRED_PASSWORD}" RLN_RELAY_CRED_PASSWORD=--rln-relay-cred-password="${RLN_RELAY_CRED_PASSWORD}"
fi fi
STORE_RETENTION_POLICY=--store-message-retention-policy=size:1GB} STORE_RETENTION_POLICY=--store-message-retention-policy=size:1GB}
if [ -n "${STORAGE_SIZE}" ]; then if [ -n "${STORAGE_SIZE}" ]; then
STORE_RETENTION_POLICY=--store-message-retention-policy=size:"${STORAGE_SIZE}" STORE_RETENTION_POLICY=--store-message-retention-policy=size:"${STORAGE_SIZE}"
fi fi
USER_REST_ALLOW_ORIGIN=
if [ -n "${ALLOW_ORIGIN}" ]; then
USER_REST_ALLOW_ORIGIN=--rest-allow-origin=\"${ALLOW_ORIGIN}\"
fi
exec /usr/bin/wakunode\ exec /usr/bin/wakunode\
--relay=true\ --relay=true\
--filter=true\ --filter=true\
@ -89,5 +92,6 @@ exec /usr/bin/wakunode\
${DNS_WSS_CMD}\ ${DNS_WSS_CMD}\
${NODEKEY}\ ${NODEKEY}\
${STORE_RETENTION_POLICY}\ ${STORE_RETENTION_POLICY}\
${USER_REST_ALLOW_ORIGIN}\
${EXTRA_ARGS} ${EXTRA_ARGS}