diff --git a/poetry.lock b/poetry.lock index a9166d66..4c9e7aea 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1519,6 +1519,7 @@ files = [ {file = "msgpack-1.0.8-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:5fbb160554e319f7b22ecf530a80a3ff496d38e8e07ae763b9e82fadfe96f273"}, {file = "msgpack-1.0.8-cp39-cp39-win32.whl", hash = "sha256:f9af38a89b6a5c04b7d18c492c8ccf2aee7048aff1ce8437c4683bb5a1df893d"}, {file = "msgpack-1.0.8-cp39-cp39-win_amd64.whl", hash = "sha256:ed59dd52075f8fc91da6053b12e8c89e37aa043f8986efd89e61fae69dc1b011"}, + {file = "msgpack-1.0.8-py3-none-any.whl", hash = "sha256:24f727df1e20b9876fa6e95f840a2a2651e34c0ad147676356f4bf5fbb0206ca"}, {file = "msgpack-1.0.8.tar.gz", hash = "sha256:95c02b0e27e706e48d0e5426d1710ca78e0f0628d6e89d5b5a5b91a5f12274f3"}, ] @@ -2603,7 +2604,6 @@ files = [ {file = "PyYAML-6.0.1-cp311-cp311-win_amd64.whl", hash = "sha256:bf07ee2fef7014951eeb99f56f39c9bb4af143d8aa3c21b1677805985307da34"}, {file = "PyYAML-6.0.1-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:855fb52b0dc35af121542a76b9a84f8d1cd886ea97c84703eaa6d88e37a2ad28"}, {file = "PyYAML-6.0.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:40df9b996c2b73138957fe23a16a4f0ba614f4c0efce1e9406a184b6d07fa3a9"}, - {file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a08c6f0fe150303c1c6b71ebcd7213c2858041a7e01975da3a99aed1e7a378ef"}, {file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6c22bec3fbe2524cde73d7ada88f6566758a8f7227bfbf93a408a9d86bcc12a0"}, {file = "PyYAML-6.0.1-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:8d4e9c88387b0f5c7d5f281e55304de64cf7f9c0021a3525bd3b1c542da3b0e4"}, {file = "PyYAML-6.0.1-cp312-cp312-win32.whl", hash = "sha256:d483d2cdf104e7c9fa60c544d92981f12ad66a457afae824d146093b8c294c54"}, @@ -3180,13 +3180,13 @@ files = [ [[package]] name = "urllib3" -version = "2.2.1" +version = "2.2.2" description = "HTTP library with thread-safe connection pooling, file post, and more." optional = false python-versions = ">=3.8" files = [ - {file = "urllib3-2.2.1-py3-none-any.whl", hash = "sha256:450b20ec296a467077128bff42b73080516e71b56ff59a60a02bef2232c4fa9d"}, - {file = "urllib3-2.2.1.tar.gz", hash = "sha256:d0570876c61ab9e520d776c38acbbb5b05a776d3f9ff98a5c8fd5162a444cf19"}, + {file = "urllib3-2.2.2-py3-none-any.whl", hash = "sha256:a448b2f64d686155468037e1ace9f2d2199776e17f0a46610480d311f73e3472"}, + {file = "urllib3-2.2.2.tar.gz", hash = "sha256:dd505485549a7a552833da5e6063639d0d177c04f23bc3864e41e5dc5f612168"}, ] [package.extras] diff --git a/src/algokit/core/sandbox.py b/src/algokit/core/sandbox.py index a1da0b5c..ca7a3d2e 100644 --- a/src/algokit/core/sandbox.py +++ b/src/algokit/core/sandbox.py @@ -56,6 +56,7 @@ def __init__(self, name: str = SANDBOX_BASE_NAME) -> None: self._latest_yaml = get_docker_compose_yml(name=f"algokit_{self.name}") self._latest_config_json = get_config_json() self._latest_algod_network_template = get_algod_network_template() + self._latest_proxy_config = get_proxy_config() @property def compose_file_path(self) -> Path: @@ -73,6 +74,10 @@ def algod_config_file_path(self) -> Path: def algod_network_template_file_path(self) -> Path: return self.directory / "algod_network_template.json" + @property + def proxy_config_file_path(self) -> Path: + return self.directory / "nginx.conf" + @classmethod def from_environment(cls) -> ComposeSandbox | None: try: @@ -128,6 +133,8 @@ def compose_file_status(self) -> ComposeFileStatus: compose_content = self.compose_file_path.read_text() config_content = self.algod_config_file_path.read_text() algod_network_template_content = self.algod_network_template_file_path.read_text() + proxy_config_content = self.proxy_config_file_path.read_text() + except FileNotFoundError: # treat as out of date if compose file exists but algod config doesn't # so that existing setups aren't suddenly reset @@ -139,6 +146,7 @@ def compose_file_status(self) -> ComposeFileStatus: compose_content == self._latest_yaml and config_content == self._latest_config_json and algod_network_template_content == self._latest_algod_network_template + and proxy_config_content == self._latest_proxy_config ): return ComposeFileStatus.UP_TO_DATE else: @@ -149,6 +157,7 @@ def write_compose_file(self) -> None: self.compose_file_path.write_text(self._latest_yaml) self.algod_config_file_path.write_text(self._latest_config_json) self.algod_network_template_file_path.write_text(self._latest_algod_network_template) + self.proxy_config_file_path.write_text(self._latest_proxy_config) def _run_compose_command( self, @@ -424,6 +433,74 @@ def get_conduit_yaml() -> str: """ +def get_proxy_config(algod_port: int = DEFAULT_ALGOD_PORT, kmd_port: int = 4002) -> str: + return f"""worker_processes 1; + +events {{ + worker_connections 1024; +}} + +http {{ + access_log off; + + map $request_method$http_access_control_request_private_network $cors_allow_private_network {{ + "OPTIONStrue" "true"; + default ""; + }} + + add_header Access-Control-Allow-Private-Network $cors_allow_private_network; + + upstream algod_api {{ + zone upstreams 64K; + server algod:8080 max_fails=1 fail_timeout=2s; + keepalive 2; + }} + + upstream kmd_api {{ + zone upstreams 64K; + server algod:7833 max_fails=1 fail_timeout=2s; + keepalive 2; + }} + + upstream indexer_api {{ + zone upstreams 64K; + server indexer:8980 max_fails=1 fail_timeout=2s; + keepalive 2; + }} + + server {{ + listen {algod_port}; + + location / {{ + proxy_set_header Host $host; + proxy_pass http://algod_api; + proxy_pass_header Server; + }} + }} + + server {{ + listen {kmd_port}; + + location / {{ + proxy_set_header Host $host; + proxy_pass http://kmd_api; + proxy_pass_header Server; + }} + }} + + server {{ + listen 8980; + + location / {{ + proxy_set_header Host $host; + proxy_pass http://indexer_api; + proxy_pass_header Server; + }} + }} +}} + """ + + def get_docker_compose_yml( name: str = "algokit_sandbox", algod_port: int = DEFAULT_ALGOD_PORT, @@ -437,8 +514,8 @@ def get_docker_compose_yml( container_name: "{name}_algod" image: {ALGORAND_IMAGE} ports: - - {algod_port}:8080 - - {kmd_port}:7833 + - 8080 + - 7833 - {tealdbg_port}:9392 environment: START_KMD: 1 @@ -483,13 +560,29 @@ def get_docker_compose_yml( container_name: "{name}_indexer" image: {INDEXER_IMAGE} ports: - - "8980:8980" + - 8980 restart: unless-stopped command: daemon --enable-all-parameters environment: INDEXER_POSTGRES_CONNECTION_STRING: "host=indexer-db port=5432 user=algorand password=algorand dbname=indexerdb sslmode=disable" depends_on: - conduit + + proxy: + container_name: "{name}_proxy" + image: nginx:1.27.0-alpine + restart: unless-stopped + ports: + - {algod_port}:{algod_port} + - {kmd_port}:{kmd_port} + - 8980:8980 + volumes: + - type: bind + source: ./nginx.conf + target: /etc/nginx/nginx.conf + depends_on: + - algod + - indexer """ # noqa: E501 diff --git a/tests/goal/test_goal.py b/tests/goal/test_goal.py index 85bc9fb1..25816336 100644 --- a/tests/goal/test_goal.py +++ b/tests/goal/test_goal.py @@ -3,7 +3,13 @@ from subprocess import CompletedProcess import pytest -from algokit.core.sandbox import ALGOD_HEALTH_URL, get_algod_network_template, get_config_json, get_docker_compose_yml +from algokit.core.sandbox import ( + ALGOD_HEALTH_URL, + get_algod_network_template, + get_config_json, + get_docker_compose_yml, + get_proxy_config, +) from pytest_httpx import HTTPXMock from pytest_mock import MockerFixture @@ -43,6 +49,7 @@ def _setup_latest_dummy_compose(app_dir_mock: AppDirs) -> None: (app_dir_mock.app_config_dir / "sandbox" / "docker-compose.yml").write_text(get_docker_compose_yml()) (app_dir_mock.app_config_dir / "sandbox" / "algod_config.json").write_text(get_config_json()) (app_dir_mock.app_config_dir / "sandbox" / "algod_network_template.json").write_text(get_algod_network_template()) + (app_dir_mock.app_config_dir / "sandbox" / "nginx.conf").write_text(get_proxy_config()) @pytest.fixture() diff --git a/tests/localnet/test_localnet_console.py b/tests/localnet/test_localnet_console.py index 7f7186a4..71cd5d9d 100644 --- a/tests/localnet/test_localnet_console.py +++ b/tests/localnet/test_localnet_console.py @@ -2,7 +2,7 @@ from subprocess import CompletedProcess import pytest -from algokit.core.sandbox import get_algod_network_template, get_config_json, get_docker_compose_yml +from algokit.core.sandbox import get_algod_network_template, get_config_json, get_docker_compose_yml, get_proxy_config from pytest_mock import MockerFixture from tests.goal.test_goal import _normalize_output @@ -25,6 +25,7 @@ def test_goal_console( (app_dir_mock.app_config_dir / "sandbox" / "docker-compose.yml").write_text(get_docker_compose_yml()) (app_dir_mock.app_config_dir / "sandbox" / "algod_config.json").write_text(get_config_json()) (app_dir_mock.app_config_dir / "sandbox" / "algod_network_template.json").write_text(get_algod_network_template()) + (app_dir_mock.app_config_dir / "sandbox" / "nginx.conf").write_text(get_proxy_config()) mocker.patch("algokit.core.proc.subprocess_run").return_value = CompletedProcess( ["docker", "exec"], 0, "STDOUT+STDERR" diff --git a/tests/localnet/test_localnet_reset.py b/tests/localnet/test_localnet_reset.py index a73a760b..3c2c821e 100644 --- a/tests/localnet/test_localnet_reset.py +++ b/tests/localnet/test_localnet_reset.py @@ -1,7 +1,7 @@ import json import pytest -from algokit.core.sandbox import get_algod_network_template, get_config_json, get_docker_compose_yml +from algokit.core.sandbox import get_algod_network_template, get_config_json, get_docker_compose_yml, get_proxy_config from tests import get_combined_verify_output from tests.utils.app_dir_mock import AppDirs @@ -52,6 +52,7 @@ def test_localnet_reset_with_existing_sandbox_with_up_to_date_config(app_dir_moc (app_dir_mock.app_config_dir / "sandbox" / "docker-compose.yml").write_text(get_docker_compose_yml()) (app_dir_mock.app_config_dir / "sandbox" / "algod_config.json").write_text(get_config_json()) (app_dir_mock.app_config_dir / "sandbox" / "algod_network_template.json").write_text(get_algod_network_template()) + (app_dir_mock.app_config_dir / "sandbox" / "nginx.conf").write_text(get_proxy_config()) result = invoke("localnet reset") @@ -83,6 +84,7 @@ def test_localnet_reset_with_named_sandbox_config(app_dir_mock: AppDirs, proc_mo (app_dir_mock.app_config_dir / "sandbox_test" / "algod_network_template.json").write_text( get_algod_network_template() ) + (app_dir_mock.app_config_dir / "sandbox_test" / "nginx.conf").write_text(get_proxy_config()) result = invoke("localnet reset") @@ -98,6 +100,7 @@ def test_localnet_reset_with_existing_sandbox_with_up_to_date_config_with_pull(a (app_dir_mock.app_config_dir / "sandbox" / "docker-compose.yml").write_text(get_docker_compose_yml()) (app_dir_mock.app_config_dir / "sandbox" / "algod_config.json").write_text(get_config_json()) (app_dir_mock.app_config_dir / "sandbox" / "algod_network_template.json").write_text(get_algod_network_template()) + (app_dir_mock.app_config_dir / "sandbox" / "nginx.conf").write_text(get_proxy_config()) result = invoke("localnet reset --update") diff --git a/tests/localnet/test_localnet_reset.test_localnet_reset_with_existing_sandbox_with_out_of_date_config.approved.txt b/tests/localnet/test_localnet_reset.test_localnet_reset_with_existing_sandbox_with_out_of_date_config.approved.txt index 5237acf5..1fb7a520 100644 --- a/tests/localnet/test_localnet_reset.test_localnet_reset_with_existing_sandbox_with_out_of_date_config.approved.txt +++ b/tests/localnet/test_localnet_reset.test_localnet_reset_with_existing_sandbox_with_out_of_date_config.approved.txt @@ -33,8 +33,8 @@ services: container_name: "algokit_sandbox_algod" image: algorand/algod:latest ports: - - 4001:8080 - - 4002:7833 + - 8080 + - 7833 - 9392:9392 environment: START_KMD: 1 @@ -79,7 +79,7 @@ services: container_name: "algokit_sandbox_indexer" image: algorand/indexer:latest ports: - - "8980:8980" + - 8980 restart: unless-stopped command: daemon --enable-all-parameters environment: @@ -87,5 +87,21 @@ services: depends_on: - conduit + proxy: + container_name: "algokit_sandbox_proxy" + image: nginx:1.27.0-alpine + restart: unless-stopped + ports: + - 4001:4001 + - 4002:4002 + - 8980:8980 + volumes: + - type: bind + source: ./nginx.conf + target: /etc/nginx/nginx.conf + depends_on: + - algod + - indexer + {app_config}/sandbox/algod_config.json { "Version": 12, "GossipFanout": 1, "EndpointAddress": "0.0.0.0:8080", "DNSBootstrapID": "", "IncomingConnectionsLimit": 0, "Archival":true, "isIndexerActive":false, "EnableDeveloperAPI":true} diff --git a/tests/localnet/test_localnet_reset.test_localnet_reset_without_existing_sandbox.approved.txt b/tests/localnet/test_localnet_reset.test_localnet_reset_without_existing_sandbox.approved.txt index 3041bac9..6a32bf40 100644 --- a/tests/localnet/test_localnet_reset.test_localnet_reset_without_existing_sandbox.approved.txt +++ b/tests/localnet/test_localnet_reset.test_localnet_reset_without_existing_sandbox.approved.txt @@ -25,8 +25,8 @@ services: container_name: "algokit_sandbox_algod" image: algorand/algod:latest ports: - - 4001:8080 - - 4002:7833 + - 8080 + - 7833 - 9392:9392 environment: START_KMD: 1 @@ -71,10 +71,26 @@ services: container_name: "algokit_sandbox_indexer" image: algorand/indexer:latest ports: - - "8980:8980" + - 8980 restart: unless-stopped command: daemon --enable-all-parameters environment: INDEXER_POSTGRES_CONNECTION_STRING: "host=indexer-db port=5432 user=algorand password=algorand dbname=indexerdb sslmode=disable" depends_on: - conduit + + proxy: + container_name: "algokit_sandbox_proxy" + image: nginx:1.27.0-alpine + restart: unless-stopped + ports: + - 4001:4001 + - 4002:4002 + - 8980:8980 + volumes: + - type: bind + source: ./nginx.conf + target: /etc/nginx/nginx.conf + depends_on: + - algod + - indexer diff --git a/tests/localnet/test_localnet_start.py b/tests/localnet/test_localnet_start.py index 57e8eaba..3102c029 100644 --- a/tests/localnet/test_localnet_start.py +++ b/tests/localnet/test_localnet_start.py @@ -9,6 +9,7 @@ get_algod_network_template, get_config_json, get_docker_compose_yml, + get_proxy_config, ) from pytest_httpx import HTTPXMock @@ -142,6 +143,7 @@ def test_localnet_start_up_to_date_definition(app_dir_mock: AppDirs) -> None: (app_dir_mock.app_config_dir / "sandbox" / "docker-compose.yml").write_text(get_docker_compose_yml()) (app_dir_mock.app_config_dir / "sandbox" / "algod_config.json").write_text(get_config_json()) (app_dir_mock.app_config_dir / "sandbox" / "algod_network_template.json").write_text(get_algod_network_template()) + (app_dir_mock.app_config_dir / "sandbox" / "nginx.conf").write_text(get_proxy_config()) result = invoke("localnet start") diff --git a/tests/localnet/test_localnet_start.test_localnet_start.approved.txt b/tests/localnet/test_localnet_start.test_localnet_start.approved.txt index 58113e6d..fdabd05e 100644 --- a/tests/localnet/test_localnet_start.test_localnet_start.approved.txt +++ b/tests/localnet/test_localnet_start.test_localnet_start.approved.txt @@ -31,8 +31,8 @@ services: container_name: "algokit_sandbox_algod" image: algorand/algod:latest ports: - - 4001:8080 - - 4002:7833 + - 8080 + - 7833 - 9392:9392 environment: START_KMD: 1 @@ -77,10 +77,26 @@ services: container_name: "algokit_sandbox_indexer" image: algorand/indexer:latest ports: - - "8980:8980" + - 8980 restart: unless-stopped command: daemon --enable-all-parameters environment: INDEXER_POSTGRES_CONNECTION_STRING: "host=indexer-db port=5432 user=algorand password=algorand dbname=indexerdb sslmode=disable" depends_on: - conduit + + proxy: + container_name: "algokit_sandbox_proxy" + image: nginx:1.27.0-alpine + restart: unless-stopped + ports: + - 4001:4001 + - 4002:4002 + - 8980:8980 + volumes: + - type: bind + source: ./nginx.conf + target: /etc/nginx/nginx.conf + depends_on: + - algod + - indexer diff --git a/tests/localnet/test_localnet_start.test_localnet_start_health_bad_status.approved.txt b/tests/localnet/test_localnet_start.test_localnet_start_health_bad_status.approved.txt index 3fe0125d..ca39bcff 100644 --- a/tests/localnet/test_localnet_start.test_localnet_start_health_bad_status.approved.txt +++ b/tests/localnet/test_localnet_start.test_localnet_start_health_bad_status.approved.txt @@ -31,8 +31,8 @@ services: container_name: "algokit_sandbox_algod" image: algorand/algod:latest ports: - - 4001:8080 - - 4002:7833 + - 8080 + - 7833 - 9392:9392 environment: START_KMD: 1 @@ -77,10 +77,26 @@ services: container_name: "algokit_sandbox_indexer" image: algorand/indexer:latest ports: - - "8980:8980" + - 8980 restart: unless-stopped command: daemon --enable-all-parameters environment: INDEXER_POSTGRES_CONNECTION_STRING: "host=indexer-db port=5432 user=algorand password=algorand dbname=indexerdb sslmode=disable" depends_on: - conduit + + proxy: + container_name: "algokit_sandbox_proxy" + image: nginx:1.27.0-alpine + restart: unless-stopped + ports: + - 4001:4001 + - 4002:4002 + - 8980:8980 + volumes: + - type: bind + source: ./nginx.conf + target: /etc/nginx/nginx.conf + depends_on: + - algod + - indexer diff --git a/tests/localnet/test_localnet_start.test_localnet_start_health_failure.approved.txt b/tests/localnet/test_localnet_start.test_localnet_start_health_failure.approved.txt index de815b4b..b832c7fa 100644 --- a/tests/localnet/test_localnet_start.test_localnet_start_health_failure.approved.txt +++ b/tests/localnet/test_localnet_start.test_localnet_start_health_failure.approved.txt @@ -30,8 +30,8 @@ services: container_name: "algokit_sandbox_algod" image: algorand/algod:latest ports: - - 4001:8080 - - 4002:7833 + - 8080 + - 7833 - 9392:9392 environment: START_KMD: 1 @@ -76,10 +76,26 @@ services: container_name: "algokit_sandbox_indexer" image: algorand/indexer:latest ports: - - "8980:8980" + - 8980 restart: unless-stopped command: daemon --enable-all-parameters environment: INDEXER_POSTGRES_CONNECTION_STRING: "host=indexer-db port=5432 user=algorand password=algorand dbname=indexerdb sslmode=disable" depends_on: - conduit + + proxy: + container_name: "algokit_sandbox_proxy" + image: nginx:1.27.0-alpine + restart: unless-stopped + ports: + - 4001:4001 + - 4002:4002 + - 8980:8980 + volumes: + - type: bind + source: ./nginx.conf + target: /etc/nginx/nginx.conf + depends_on: + - algod + - indexer diff --git a/tests/localnet/test_localnet_start.test_localnet_start_with_name.approved.txt b/tests/localnet/test_localnet_start.test_localnet_start_with_name.approved.txt index 9c606eec..7014da91 100644 --- a/tests/localnet/test_localnet_start.test_localnet_start_with_name.approved.txt +++ b/tests/localnet/test_localnet_start.test_localnet_start_with_name.approved.txt @@ -34,8 +34,8 @@ services: container_name: "algokit_sandbox_test_algod" image: algorand/algod:latest ports: - - 4001:8080 - - 4002:7833 + - 8080 + - 7833 - 9392:9392 environment: START_KMD: 1 @@ -80,10 +80,26 @@ services: container_name: "algokit_sandbox_test_indexer" image: algorand/indexer:latest ports: - - "8980:8980" + - 8980 restart: unless-stopped command: daemon --enable-all-parameters environment: INDEXER_POSTGRES_CONNECTION_STRING: "host=indexer-db port=5432 user=algorand password=algorand dbname=indexerdb sslmode=disable" depends_on: - conduit + + proxy: + container_name: "algokit_sandbox_test_proxy" + image: nginx:1.27.0-alpine + restart: unless-stopped + ports: + - 4001:4001 + - 4002:4002 + - 8980:8980 + volumes: + - type: bind + source: ./nginx.conf + target: /etc/nginx/nginx.conf + depends_on: + - algod + - indexer diff --git a/tests/localnet/test_sandbox.py b/tests/localnet/test_sandbox.py index d27cd27e..4d389e62 100644 --- a/tests/localnet/test_sandbox.py +++ b/tests/localnet/test_sandbox.py @@ -1,6 +1,12 @@ import json -from algokit.core.sandbox import get_algod_network_template, get_conduit_yaml, get_config_json, get_docker_compose_yml +from algokit.core.sandbox import ( + get_algod_network_template, + get_conduit_yaml, + get_config_json, + get_docker_compose_yml, + get_proxy_config, +) from tests.utils.approvals import verify @@ -23,3 +29,8 @@ def test_get_docker_compose_yml() -> None: def test_algod_network_template_json() -> None: algod_network_template_json = get_algod_network_template() verify(algod_network_template_json) + + +def test_proxy_config() -> None: + proxy_config = get_proxy_config() + verify(proxy_config) diff --git a/tests/localnet/test_sandbox.test_get_docker_compose_yml.approved.txt b/tests/localnet/test_sandbox.test_get_docker_compose_yml.approved.txt index 6f22f0bd..a246d3f5 100644 --- a/tests/localnet/test_sandbox.test_get_docker_compose_yml.approved.txt +++ b/tests/localnet/test_sandbox.test_get_docker_compose_yml.approved.txt @@ -5,8 +5,8 @@ services: container_name: "algokit_sandbox_algod" image: algorand/algod:latest ports: - - 4001:8080 - - 4002:7833 + - 8080 + - 7833 - 9392:9392 environment: START_KMD: 1 @@ -51,10 +51,26 @@ services: container_name: "algokit_sandbox_indexer" image: algorand/indexer:latest ports: - - "8980:8980" + - 8980 restart: unless-stopped command: daemon --enable-all-parameters environment: INDEXER_POSTGRES_CONNECTION_STRING: "host=indexer-db port=5432 user=algorand password=algorand dbname=indexerdb sslmode=disable" depends_on: - conduit + + proxy: + container_name: "algokit_sandbox_proxy" + image: nginx:1.27.0-alpine + restart: unless-stopped + ports: + - 4001:4001 + - 4002:4002 + - 8980:8980 + volumes: + - type: bind + source: ./nginx.conf + target: /etc/nginx/nginx.conf + depends_on: + - algod + - indexer diff --git a/tests/localnet/test_sandbox.test_proxy_config.approved.txt b/tests/localnet/test_sandbox.test_proxy_config.approved.txt new file mode 100644 index 00000000..1d17bf42 --- /dev/null +++ b/tests/localnet/test_sandbox.test_proxy_config.approved.txt @@ -0,0 +1,65 @@ +worker_processes 1; + +events { + worker_connections 1024; +} + +http { + access_log off; + + map $request_method$http_access_control_request_private_network $cors_allow_private_network { + "OPTIONStrue" "true"; + default ""; + } + + add_header Access-Control-Allow-Private-Network $cors_allow_private_network; + + upstream algod_api { + zone upstreams 64K; + server algod:8080 max_fails=1 fail_timeout=2s; + keepalive 2; + } + + upstream kmd_api { + zone upstreams 64K; + server algod:7833 max_fails=1 fail_timeout=2s; + keepalive 2; + } + + upstream indexer_api { + zone upstreams 64K; + server indexer:8980 max_fails=1 fail_timeout=2s; + keepalive 2; + } + + server { + listen 4001; + + location / { + proxy_set_header Host $host; + proxy_pass http://algod_api; + proxy_pass_header Server; + } + } + + server { + listen 4002; + + location / { + proxy_set_header Host $host; + proxy_pass http://kmd_api; + proxy_pass_header Server; + } + } + + server { + listen 8980; + + location / { + proxy_set_header Host $host; + proxy_pass http://indexer_api; + proxy_pass_header Server; + } + } +} +