feat: docker-compose.yml per node, minimal nginx config
- /opt/fw/{name}/docker-compose.yml — declarative, editable
- /opt/fw/{name}/nginx/default.conf — user-editable
- docker compose up -d for deployment
- Remove rate limits and header manipulation (app handles it)
This commit is contained in:
parent
c4f2c8fadb
commit
f9c2771984
1 changed files with 26 additions and 25 deletions
|
|
@ -62,21 +62,15 @@ def deploy_container(name, token, cloud, port, upstream_ip, upstream_port, label
|
||||||
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"""server {{
|
||||||
listen {port};
|
listen 80;
|
||||||
server_name _;
|
server_name _;
|
||||||
set_real_ip_from 10.0.0.0/8;
|
|
||||||
real_ip_header X-Real-IP;
|
|
||||||
real_ip_recursive on;
|
|
||||||
|
|
||||||
location /wallarm-status {{
|
location /wallarm-status {{
|
||||||
wallarm_status on;
|
wallarm_status on;
|
||||||
allow 127.0.0.0/8;
|
allow 127.0.0.0/8;
|
||||||
deny all;
|
deny all;
|
||||||
}}
|
}}
|
||||||
location /health {{
|
|
||||||
access_log off;
|
|
||||||
return 200 "healthy\n";
|
|
||||||
}}
|
|
||||||
location / {{
|
location / {{
|
||||||
proxy_pass http://{upstream_ip}:{upstream_port};
|
proxy_pass http://{upstream_ip}:{upstream_port};
|
||||||
proxy_set_header Host $host;
|
proxy_set_header Host $host;
|
||||||
|
|
@ -87,24 +81,31 @@ def deploy_container(name, token, cloud, port, upstream_ip, upstream_port, label
|
||||||
}}
|
}}
|
||||||
""")
|
""")
|
||||||
|
|
||||||
# Run container
|
# Generate docker-compose.yml + start
|
||||||
monitoring_port = int(port) + 10
|
compose_path = f"{host_dir}/docker-compose.yml"
|
||||||
print(f"[{name}] Starting container on port {port}...")
|
with open(compose_path, "w") as f:
|
||||||
cmd = f"""docker run -d \
|
f.write(f"""services:
|
||||||
--name {container} \
|
wallarm:
|
||||||
--restart unless-stopped \
|
image: {WALLARM_IMAGE}
|
||||||
-p {port}:{port} \
|
container_name: {container}
|
||||||
-v {host_dir}/nginx:/etc/nginx/http.d:ro -v {host_dir}/etc:/opt/wallarm/etc \
|
restart: always
|
||||||
-p {monitoring_port}:{monitoring_port} \
|
ports:
|
||||||
-e WALLARM_API_TOKEN={token} \
|
- "{port}:80"
|
||||||
-e WALLARM_API_HOST={api_host} \
|
environment:
|
||||||
-e WALLARM_MODE={mode} \
|
- WALLARM_API_TOKEN={token}
|
||||||
-e NGINX_PORT={port}"""
|
- WALLARM_API_HOST={api_host}
|
||||||
if upstream_ip:
|
- WALLARM_MODE={mode}
|
||||||
cmd += f" -e WALLARM_UPSTREAM=http://{upstream_ip}:{upstream_port}"
|
volumes:
|
||||||
cmd += f" {WALLARM_IMAGE}"
|
- ./nginx/default.conf:/etc/nginx/http.d/default.conf:ro
|
||||||
|
- ./etc:/opt/wallarm/etc
|
||||||
|
logging:
|
||||||
|
driver: json-file
|
||||||
|
options:
|
||||||
|
max-size: 10m
|
||||||
|
""")
|
||||||
|
|
||||||
r = run(cmd, timeout=30)
|
print(f"[{name}] Starting via compose...")
|
||||||
|
r = run(f"cd {host_dir} && docker compose up -d", timeout=30)
|
||||||
if r.returncode != 0:
|
if r.returncode != 0:
|
||||||
print(f"❌ {name}: {r.stderr}")
|
print(f"❌ {name}: {r.stderr}")
|
||||||
return False
|
return False
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue