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):
|
||||
with open(nginx_conf, "w") as f:
|
||||
f.write(f"""server {{
|
||||
listen {port};
|
||||
listen 80;
|
||||
server_name _;
|
||||
set_real_ip_from 10.0.0.0/8;
|
||||
real_ip_header X-Real-IP;
|
||||
real_ip_recursive on;
|
||||
|
||||
location /wallarm-status {{
|
||||
wallarm_status on;
|
||||
allow 127.0.0.0/8;
|
||||
deny all;
|
||||
}}
|
||||
location /health {{
|
||||
access_log off;
|
||||
return 200 "healthy\n";
|
||||
}}
|
||||
|
||||
location / {{
|
||||
proxy_pass http://{upstream_ip}:{upstream_port};
|
||||
proxy_set_header Host $host;
|
||||
|
|
@ -87,24 +81,31 @@ def deploy_container(name, token, cloud, port, upstream_ip, upstream_port, label
|
|||
}}
|
||||
""")
|
||||
|
||||
# Run container
|
||||
monitoring_port = int(port) + 10
|
||||
print(f"[{name}] Starting container on port {port}...")
|
||||
cmd = f"""docker run -d \
|
||||
--name {container} \
|
||||
--restart unless-stopped \
|
||||
-p {port}:{port} \
|
||||
-v {host_dir}/nginx:/etc/nginx/http.d:ro -v {host_dir}/etc:/opt/wallarm/etc \
|
||||
-p {monitoring_port}:{monitoring_port} \
|
||||
-e WALLARM_API_TOKEN={token} \
|
||||
-e WALLARM_API_HOST={api_host} \
|
||||
-e WALLARM_MODE={mode} \
|
||||
-e NGINX_PORT={port}"""
|
||||
if upstream_ip:
|
||||
cmd += f" -e WALLARM_UPSTREAM=http://{upstream_ip}:{upstream_port}"
|
||||
cmd += f" {WALLARM_IMAGE}"
|
||||
# Generate docker-compose.yml + start
|
||||
compose_path = f"{host_dir}/docker-compose.yml"
|
||||
with open(compose_path, "w") as f:
|
||||
f.write(f"""services:
|
||||
wallarm:
|
||||
image: {WALLARM_IMAGE}
|
||||
container_name: {container}
|
||||
restart: always
|
||||
ports:
|
||||
- "{port}:80"
|
||||
environment:
|
||||
- WALLARM_API_TOKEN={token}
|
||||
- WALLARM_API_HOST={api_host}
|
||||
- WALLARM_MODE={mode}
|
||||
volumes:
|
||||
- ./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:
|
||||
print(f"❌ {name}: {r.stderr}")
|
||||
return False
|
||||
|
|
|
|||
Loading…
Reference in a new issue