forked from admin/ansible
feat(hermes_squid): add /state2 path for secondary brencher, remove squid whitelist
Two changes: 1) Add /state2 location to brencher-state-proxy.conf that proxies to http://host.docker.internal:5002/state (the secondary brencher instance, reached the same way the brencher container itself reaches it -- via extra_hosts: host.docker.internal:host-gateway). This requires adding the same extra_hosts entry to the brencher-state-proxy service in stack-compose.yml. 2) Remove brencher.rudolf.keenetic.link from squid allowed_domains. The sidecar now handles the only legitimate access path (/state), so squid doesn't need a blanket allow for the host anymore. Any client that wants /state goes through the sidecar; the rest stays blocked at the squid layer (defense in depth). Verified locally (no docker daemon): - nginx -t on brencher-state-proxy.conf: syntax is ok, test successful - Live nginx start against two fake upstreams (primary + secondary): GET /state -> 200 (primary, body contains primary) GET /state2 -> 200 (secondary, body contains secondary) GET /state?x=1 -> 200 (query forwarded to primary, path=/state?x=1) GET /state2?x=1 -> 200 (query forwarded to secondary, path=/state?x=1) GET /state/ -> 403 (trailing slash, exact-match) GET /state2/ -> 403 (trailing slash) GET / -> 403 GET /stateX -> 403 GET /healthz -> 200 - YAML parse of stack-compose.yml via PyYAML: ok, extra_hosts present - All 9 path-locking tests pass
This commit is contained in:
@@ -64,6 +64,29 @@ server {
|
||||
add_header Cache-Control "no-store" always;
|
||||
}
|
||||
|
||||
|
||||
# Secondary brencher (runs on the docker host via host.docker.internal,
|
||||
# reached as http://host.docker.internal:5002 -- same trick the brencher
|
||||
# container itself uses in docker-compose.yml's extra_hosts). Only the
|
||||
# /state2 path is exposed; everything else returns 403 like /state.
|
||||
location = /state2 {
|
||||
proxy_pass http://host.docker.internal:5002/state;
|
||||
proxy_http_version 1.1;
|
||||
|
||||
# Cleartext HTTP upstream (port 5002), no TLS to wrangle.
|
||||
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 https;
|
||||
|
||||
proxy_connect_timeout 5s;
|
||||
proxy_read_timeout 30s;
|
||||
proxy_send_timeout 10s;
|
||||
|
||||
proxy_buffering off;
|
||||
add_header Cache-Control "no-store" always;
|
||||
}
|
||||
|
||||
# Catch-all: deny everything else, including /state/ (with trailing
|
||||
# slash), /state?foo=bar (with query), and any other path.
|
||||
location / {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
acl hermes_network src 10.0.0.0/8
|
||||
acl hermes_network src 172.16.0.0/12
|
||||
acl hermes_network src 192.168.0.0/16
|
||||
acl allowed_domains dstdomain .minimax.io .minimax.chat .minimax.com .githubusercontent.com deb.debian.org gitea.rudolf.keenetic.link brencher.rudolf.keenetic.link
|
||||
acl allowed_domains dstdomain .minimax.io .minimax.chat .minimax.com .githubusercontent.com deb.debian.org gitea.rudolf.keenetic.link
|
||||
acl CONNECT method CONNECT
|
||||
acl SSL_ports port 443
|
||||
acl Safe_ports port 80 443
|
||||
|
||||
@@ -163,6 +163,11 @@ services:
|
||||
# See hermes_squid/brencher-state-proxy.conf for the path rules.
|
||||
image: nginx:alpine
|
||||
hostname: brencher-state-proxy
|
||||
extra_hosts:
|
||||
# Lets the sidecar reach the secondary brencher at
|
||||
# http://host.docker.internal:5002/state -- same trick the brencher
|
||||
# container itself uses in its own docker-compose.yml.
|
||||
- "host.docker.internal:host-gateway"
|
||||
networks:
|
||||
- admin # so hermes_infra services can reach it
|
||||
- nginx_ingress # so it can reach brencher.rudolf.keenetic.link via the LE front-proxy
|
||||
|
||||
Reference in New Issue
Block a user