fix: proper nginx config with proxy headers, mount http.d/default.conf
This commit is contained in:
parent
643a8fbe23
commit
c4f2c8fadb
1 changed files with 24 additions and 10 deletions
|
|
@ -58,17 +58,31 @@ def deploy_container(name, token, cloud, port, upstream_ip, upstream_port, label
|
||||||
os.makedirs(f"{host_dir}/etc", exist_ok=True)
|
os.makedirs(f"{host_dir}/etc", exist_ok=True)
|
||||||
os.makedirs(f"{host_dir}/nginx", exist_ok=True)
|
os.makedirs(f"{host_dir}/nginx", exist_ok=True)
|
||||||
# Write default nginx config if not exists
|
# Write default nginx config if not exists
|
||||||
nginx_conf = f"{host_dir}/nginx/nginx.conf"
|
nginx_conf = f"{host_dir}/nginx/default.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"""load_module /opt/wallarm/modules/nginx_v1.26.3_s0ff5dffff/ngx_http_wallarm_module.so;
|
f.write(f"""server {{
|
||||||
events {{ worker_connections 10240; }}
|
|
||||||
http {{
|
|
||||||
wallarm_mode {mode};
|
|
||||||
server {{
|
|
||||||
listen {port};
|
listen {port};
|
||||||
location /wallarm-status {{ wallarm_status on; }}
|
server_name _;
|
||||||
location / {{ proxy_pass http://{upstream_ip}:{upstream_port}; }}
|
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;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
}}
|
}}
|
||||||
}}
|
}}
|
||||||
""")
|
""")
|
||||||
|
|
@ -80,7 +94,7 @@ http {{
|
||||||
--name {container} \
|
--name {container} \
|
||||||
--restart unless-stopped \
|
--restart unless-stopped \
|
||||||
-p {port}:{port} \
|
-p {port}:{port} \
|
||||||
-v {host_dir}/nginx:/etc/nginx -v {host_dir}/etc:/opt/wallarm/etc \
|
-v {host_dir}/nginx:/etc/nginx/http.d:ro -v {host_dir}/etc:/opt/wallarm/etc \
|
||||||
-p {monitoring_port}:{monitoring_port} \
|
-p {monitoring_port}:{monitoring_port} \
|
||||||
-e WALLARM_API_TOKEN={token} \
|
-e WALLARM_API_TOKEN={token} \
|
||||||
-e WALLARM_API_HOST={api_host} \
|
-e WALLARM_API_HOST={api_host} \
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue