diff --git a/stack_orchestrator/data/compose/docker-compose-go-nitro-auth.yml b/stack_orchestrator/data/compose/docker-compose-go-nitro-auth.yml index 7840ad66..dff40436 100644 --- a/stack_orchestrator/data/compose/docker-compose-go-nitro-auth.yml +++ b/stack_orchestrator/data/compose/docker-compose-go-nitro-auth.yml @@ -94,7 +94,7 @@ services: hostname: nitro-rpc-client restart: always environment: - CERC_NITRO_RPC_FUND_AMOUNT: ${CERC_NITRO_RPC_FUND_AMOUNT:-0} + CERC_NITRO_RPC_FUND_AMOUNT: ${CERC_NITRO_RPC_FUND_AMOUNT:-2000000} CERC_NITRO_RPC_HOST_ALICE: ${CERC_NITRO_RPC_HOST_ALICE:-go-nitro-alice} CERC_NITRO_RPC_PORT_ALICE: ${CERC_NITRO_RPC_PORT_ALICE:-4006} CERC_NITRO_USE_TLS: ${CERC_NITRO_USE_TLS:-false} @@ -104,13 +104,24 @@ services: - ../config/nitro-rpc-client/start.sh:/app/start.sh command: ["/app/start.sh"] - nitro-nginx: - image: nginx:1.23-alpine + #nitro-nginx: + # image: nginx:1.23-alpine + # restart: always + # volumes: + # - ../config/go-nitro-auth/nginx:/etc/nginx/conf.d + # ports: + # - 5678:80 + # depends_on: + # - go-nitro-alice + # - go-nitro-bob + + nitro-caddy: + image: caddy:2-alpine restart: always volumes: - - ../config/go-nitro-auth/nginx:/etc/nginx/conf.d + - ../config/go-nitro-auth/caddy/Caddyfile:/etc/caddy/Caddyfile ports: - - 5678:80 + - "5678:80" depends_on: - go-nitro-alice - go-nitro-bob diff --git a/stack_orchestrator/data/config/go-nitro-auth/caddy/Caddyfile b/stack_orchestrator/data/config/go-nitro-auth/caddy/Caddyfile new file mode 100644 index 00000000..a0d1d9d3 --- /dev/null +++ b/stack_orchestrator/data/config/go-nitro-auth/caddy/Caddyfile @@ -0,0 +1,38 @@ +:80 { + handle /pay* { + reverse_proxy http://go-nitro-bob:8547 + } + + @eth-key-in-header { + path_regexp /eth/?$ + header X-Api-Key * + } + + handle @eth-key-in-header { + forward_auth go-nitro-bob:8547 { + uri /auth/{header.x-api-key} + } + rewrite * / + reverse_proxy http://fixturenet-eth-geth-1:8545 + } + + @eth-key-in-path { + path_regexp apikey eth/(.+)$ + } + + handle @eth-key-in-path { + forward_auth go-nitro-bob:8547 { + uri /auth/{re.apikey.1} + } + rewrite * / + reverse_proxy http://fixturenet-eth-geth-1:8545 + } + + handle /eth* { + respond "401 Unauthorized" 401 + } + + handle { + reverse_proxy http://go-nitro-alice:4206 + } +} \ No newline at end of file diff --git a/stack_orchestrator/data/config/go-nitro-auth/nginx/nitro_auth_proxy.conf b/stack_orchestrator/data/config/go-nitro-auth/nginx/nitro_auth_proxy.conf index 28ed62fa..5bd5f0f3 100644 --- a/stack_orchestrator/data/config/go-nitro-auth/nginx/nitro_auth_proxy.conf +++ b/stack_orchestrator/data/config/go-nitro-auth/nginx/nitro_auth_proxy.conf @@ -34,10 +34,10 @@ server { } ## payments - location /pay { - proxy_buffering off; - proxy_pass http://go-nitro-bob:8547/pay; - } + location /pay { + proxy_buffering off; + proxy_pass http://go-nitro-bob:8547/pay; + } location = /auth { internal; diff --git a/stack_orchestrator/data/config/go-nitro/run-nitro-node.sh b/stack_orchestrator/data/config/go-nitro/run-nitro-node.sh index 3cf4279d..732af9aa 100755 --- a/stack_orchestrator/data/config/go-nitro/run-nitro-node.sh +++ b/stack_orchestrator/data/config/go-nitro/run-nitro-node.sh @@ -49,7 +49,7 @@ done if [[ -n "$CERC_NITRO_UI_PORT" ]] && [[ -d "/app-node/packages/nitro-gui/dist" ]]; then for f in `ls /app-node/packages/nitro-gui/dist/assets/*.js`; do - sed -i "s#\"CERC_RUNTIME_ENV_RPC_URL\"#\"http://localhost:${CERC_NITRO_RPC_PORT}\"#g" "$f" + sed -i "s#\"CERC_RUNTIME_ENV_RPC_HOST\"#\"localhost:${CERC_NITRO_RPC_PORT}\"#g" "$f" sed -i "s#\"CERC_RUNTIME_ENV_TARGET_URL\"#\"http://localhost:5678\"#g" "$f" done http-server -p $CERC_NITRO_UI_PORT /app-node/packages/nitro-gui/dist & diff --git a/stack_orchestrator/data/container-build/cerc-go-nitro/Dockerfile b/stack_orchestrator/data/container-build/cerc-go-nitro/Dockerfile index 27382f95..331cadad 100644 --- a/stack_orchestrator/data/container-build/cerc-go-nitro/Dockerfile +++ b/stack_orchestrator/data/container-build/cerc-go-nitro/Dockerfile @@ -17,7 +17,7 @@ RUN find . -name 'node_modules' | xargs -n1 rm -rf RUN find . -name 'dist' | xargs -n1 rm -rf RUN yarn WORKDIR /app/packages/nitro-gui -RUN VITE_RPC_URL=CERC_RUNTIME_ENV_RPC_URL VITE_TARGET_URL=CERC_RUNTIME_ENV_TARGET_URL yarn build +RUN VITE_RPC_HOST=CERC_RUNTIME_ENV_RPC_HOST yarn build WORKDIR /app/packages/nitro-auth-gui RUN VITE_RPC_URL=CERC_RUNTIME_ENV_RPC_URL VITE_TARGET_URL=CERC_RUNTIME_ENV_TARGET_URL yarn build WORKDIR /app/packages/nitro-auth