From 9c6ddd2da1ac16b6955cfd43150063b9f4ec64a6 Mon Sep 17 00:00:00 2001 From: admin Date: Mon, 3 Aug 2026 17:38:53 +0000 Subject: [PATCH] fix: use NGINX_BACKEND env var (image auto-generates nginx) --- sources/python/main.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/sources/python/main.py b/sources/python/main.py index 7a396f0..7ffb4d0 100644 --- a/sources/python/main.py +++ b/sources/python/main.py @@ -57,7 +57,8 @@ def deploy_container(name, token, cloud, port, upstream_ip, upstream_port, label host_dir = f"{BASE}/{name}" os.makedirs(host_dir, exist_ok=True) - # Generate start.sh (declarative config + startup in one file) + # Generate start.sh + upstream = f"{upstream_ip}:{upstream_port}" start_path = f"{host_dir}/start.sh" with open(start_path, "w") as f: f.write(f"""#!/bin/bash @@ -70,18 +71,20 @@ docker run -d \\ -e WALLARM_API_TOKEN='{token}' \\ -e WALLARM_API_HOST={api_host} \\ -e WALLARM_MODE={mode} \\ - -v {host_dir}/nginx.conf:/etc/nginx/http.d/default.conf:ro \\ + -e NGINX_BACKEND={upstream} \\ {WALLARM_IMAGE} sleep 3 docker ps --filter name={container} --format '{{{{.Status}}}}' """) os.chmod(start_path, 0o755) - # Write nginx.conf with production defaults + # Nginx config for optional customization nginx_conf = f"{host_dir}/nginx.conf" if not os.path.exists(nginx_conf): with open(nginx_conf, "w") as f: - f.write(f"""server {{ + f.write(f"""# Wallarm node: {name} +# Mount with: -v $(pwd)/nginx.conf:/etc/nginx/http.d/default.conf:ro +server {{ listen 80; server_name _; client_max_body_size 1024m; @@ -95,7 +98,7 @@ docker ps --filter name={container} --format '{{{{.Status}}}}' }} location / {{ - proxy_pass http://{upstream_ip}:{upstream_port}; + proxy_pass http://{upstream}; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;