fix: use NGINX_BACKEND env var (image auto-generates nginx)

This commit is contained in:
admin 2026-08-03 17:38:53 +00:00
parent 202f0e2dc8
commit 9c6ddd2da1

View file

@ -57,7 +57,8 @@ def deploy_container(name, token, cloud, port, upstream_ip, upstream_port, label
host_dir = f"{BASE}/{name}" host_dir = f"{BASE}/{name}"
os.makedirs(host_dir, exist_ok=True) 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" start_path = f"{host_dir}/start.sh"
with open(start_path, "w") as f: with open(start_path, "w") as f:
f.write(f"""#!/bin/bash f.write(f"""#!/bin/bash
@ -70,18 +71,20 @@ docker run -d \\
-e WALLARM_API_TOKEN='{token}' \\ -e WALLARM_API_TOKEN='{token}' \\
-e WALLARM_API_HOST={api_host} \\ -e WALLARM_API_HOST={api_host} \\
-e WALLARM_MODE={mode} \\ -e WALLARM_MODE={mode} \\
-v {host_dir}/nginx.conf:/etc/nginx/http.d/default.conf:ro \\ -e NGINX_BACKEND={upstream} \\
{WALLARM_IMAGE} {WALLARM_IMAGE}
sleep 3 sleep 3
docker ps --filter name={container} --format '{{{{.Status}}}}' docker ps --filter name={container} --format '{{{{.Status}}}}'
""") """)
os.chmod(start_path, 0o755) os.chmod(start_path, 0o755)
# Write nginx.conf with production defaults # Nginx config for optional customization
nginx_conf = f"{host_dir}/nginx.conf" nginx_conf = f"{host_dir}/nginx.conf"
if not os.path.exists(nginx_conf): if not os.path.exists(nginx_conf):
with open(nginx_conf, "w") as f: 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; listen 80;
server_name _; server_name _;
client_max_body_size 1024m; client_max_body_size 1024m;
@ -95,7 +98,7 @@ docker ps --filter name={container} --format '{{{{.Status}}}}'
}} }}
location / {{ location / {{
proxy_pass http://{upstream_ip}:{upstream_port}; proxy_pass http://{upstream};
proxy_set_header Host $host; proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;