From ad8bf0f438d6566985d6357779ec82204be33211 Mon Sep 17 00:00:00 2001 From: Andy Tang Date: Thu, 6 Feb 2025 10:18:30 +0100 Subject: [PATCH 1/2] Add nginx --- devnet/docker-compose.yml | 9 +++++++++ devnet/nginx.conf | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 devnet/nginx.conf diff --git a/devnet/docker-compose.yml b/devnet/docker-compose.yml index 86600bb..3a76581 100644 --- a/devnet/docker-compose.yml +++ b/devnet/docker-compose.yml @@ -215,3 +215,12 @@ services: source ./functions.sh info $$HEIGHT + nginx: + image: nginx:alpine + ports: + - 8888:80 + volumes: + - ./nginx.conf:/etc/nginx/conf.d/default.conf:ro + depends_on: + - chainweb-evm-chain0 + - chainweb-evm-chain1 diff --git a/devnet/nginx.conf b/devnet/nginx.conf new file mode 100644 index 0000000..94a3185 --- /dev/null +++ b/devnet/nginx.conf @@ -0,0 +1,39 @@ +server { + listen 80; + + location /devnet1/ { + if ($request_method = 'OPTIONS') { + add_header 'Access-Control-Allow-Origin' '*'; + add_header 'Access-Control-Allow-Credentials' 'true'; + add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; + add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type'; + add_header 'Access-Control-Max-Age' 1728000; + add_header 'Content-Type' 'text/plain charset=UTF-8'; + add_header 'Content-Length' 0; + return 204; + } + add_header 'Access-Control-Allow-Origin' '*'; + add_header 'Access-Control-Allow-Credentials' 'true'; + add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; + add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type'; + proxy_pass http://chainweb-evm-chain0:8545/; + } + + location /devnet2/ { + if ($request_method = 'OPTIONS') { + add_header 'Access-Control-Allow-Origin' '*'; + add_header 'Access-Control-Allow-Credentials' 'true'; + add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; + add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type'; + add_header 'Access-Control-Max-Age' 1728000; + add_header 'Content-Type' 'text/plain charset=UTF-8'; + add_header 'Content-Length' 0; + return 204; + } + add_header 'Access-Control-Allow-Origin' '*'; + add_header 'Access-Control-Allow-Credentials' 'true'; + add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; + add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type'; + proxy_pass http://chainweb-evm-chain1:8555/; + } +} From a9343d7b23b8c91ede4c8b8834bc3084d01b257e Mon Sep 17 00:00:00 2001 From: Andy Tang Date: Thu, 6 Feb 2025 13:35:10 +0100 Subject: [PATCH 2/2] Add nginx ports to be exposed via the show-ports command --- devnet/docker-compose.yml | 1 + network | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/devnet/docker-compose.yml b/devnet/docker-compose.yml index 3a76581..72c9120 100644 --- a/devnet/docker-compose.yml +++ b/devnet/docker-compose.yml @@ -216,6 +216,7 @@ services: info $$HEIGHT nginx: + container_name: chainweb-evm-nginx image: nginx:alpine ports: - 8888:80 diff --git a/network b/network index e0156ed..06bdb25 100755 --- a/network +++ b/network @@ -153,7 +153,7 @@ function blockscout () { # Devnet function show-ports () { - for i in chainweb-node chainweb-miner chainweb-evm-chain0 chainweb-evm-chain1 ; do + for i in chainweb-node chainweb-miner chainweb-evm-chain0 chainweb-evm-chain1 chainweb-evm-nginx ; do echo "$i:" docker port $i echo