Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6848d114a7 |
@@ -1,97 +0,0 @@
|
||||
# nginx config for the brencher-state-proxy sidecar.
|
||||
#
|
||||
# Path-locked reverse proxy for the brencher /state endpoint:
|
||||
# - /state -> proxied to https://brencher.rudolf.keenetic.link/state
|
||||
# - everything else -> 403 Forbidden
|
||||
#
|
||||
# This lets hermes-agent reach /state without going through squid's
|
||||
# host-level allowlist (which can't see inside TLS) and without exposing
|
||||
# the rest of brencher's surface area.
|
||||
#
|
||||
# Listen on 8080 (plain HTTP). No TLS -- this is a private internal
|
||||
# API on the admin overlay, reachable only from inside the swarm. No
|
||||
# host port is published.
|
||||
#
|
||||
# Upstream is the public URL on purpose -- the sidecar reaches the public
|
||||
# brencher.rudolf.keenetic.link through the nginx-ingress overlay the same
|
||||
# way any external client would, which means it doesn't need to be on the
|
||||
# brencher container's private networks.
|
||||
|
||||
server {
|
||||
listen 8080;
|
||||
server_name _;
|
||||
|
||||
resolver 127.0.0.11 192.168.1.1 valid=30s ipv6=off;
|
||||
resolver_timeout 5s;
|
||||
|
||||
# Tiny access log; default nginx format
|
||||
access_log /var/log/nginx/brencher-state-access.log;
|
||||
error_log /var/log/nginx/brencher-state-error.log warn;
|
||||
|
||||
# Healthcheck for swarm -- not /state, deliberately, so a 200 here
|
||||
# doesn't accidentally imply /state is reachable from outside the
|
||||
# allowlist.
|
||||
location = /healthz {
|
||||
access_log off;
|
||||
return 200 "ok\n";
|
||||
add_header Content-Type text/plain;
|
||||
}
|
||||
|
||||
# The only allowed path. Exact match: query strings or trailing
|
||||
# anything else fall through to the default 403.
|
||||
location = /state {
|
||||
set $brencher_upstream https://brencher.rudolf.keenetic.link;
|
||||
proxy_pass $brencher_upstream/state;
|
||||
proxy_http_version 1.1;
|
||||
|
||||
# Upstream is HTTPS; the sidecar trusts the LE-issued cert via
|
||||
# the system CA bundle. SNI explicitly named so any future
|
||||
# transparent-proxy middlebox doesn't break the handshake.
|
||||
proxy_ssl_server_name on;
|
||||
proxy_ssl_name brencher.rudolf.keenetic.link;
|
||||
|
||||
proxy_set_header Host brencher.rudolf.keenetic.link;
|
||||
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;
|
||||
|
||||
# Don't cache -- state should be live.
|
||||
proxy_buffering off;
|
||||
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 / {
|
||||
access_log off;
|
||||
return 403 "forbidden: only /state is allowed through this proxy\n";
|
||||
add_header Content-Type text/plain;
|
||||
}
|
||||
}
|
||||
@@ -64,10 +64,10 @@ services:
|
||||
command: gateway run
|
||||
user: "0:0"
|
||||
networks:
|
||||
# No admin overlay membership here: the sidecars (brencher-state-proxy,
|
||||
# docker_socket_proxy) are on hermes_proxy too, so DNS resolves
|
||||
# without expanding hermes-gateway's L3 footprint. The NO_PROXY
|
||||
# list below ensures those requests skip squid.
|
||||
# No admin overlay membership here: the docker_socket_proxy sidecar
|
||||
# is on hermes_proxy too, so DNS resolves without expanding
|
||||
# hermes-gateway's L3 footprint. The NO_PROXY list below ensures
|
||||
# those requests skip squid.
|
||||
- hermes_proxy
|
||||
volumes:
|
||||
- hermes_gateway_data:/opt/data
|
||||
@@ -84,21 +84,21 @@ services:
|
||||
HTTPS_PROXY: http://squid:3128
|
||||
http_proxy: http://squid:3128
|
||||
https_proxy: http://squid:3128
|
||||
# The sidecars added in this PR (brencher-state-proxy, docker_socket_proxy)
|
||||
# are reachable on the hermes_proxy overlay. They are NOT public services, so
|
||||
# traffic to them MUST NOT be routed through squid (which can't reach
|
||||
# them anyway and would 403 the request).
|
||||
# The docker_socket_proxy sidecar is reachable on the hermes_proxy
|
||||
# overlay. It is NOT a public service, so traffic to it MUST NOT be
|
||||
# routed through squid (which can't reach it anyway and would 403
|
||||
# the request).
|
||||
# Comma-separated list. Format accepted by curl/requests/urllib:
|
||||
# bare hostnames, IPs, CIDR ranges. Order doesn't matter; case-insensitive.
|
||||
# 127.0.0.1 - loopback
|
||||
# .local - mDNS / link-local (covers host.docker.internal)
|
||||
# squid, hermes-gateway, hermes-agent - same-overlay services that
|
||||
# hermes-gateway itself needs to talk to without going through squid
|
||||
# brencher-state-proxy, docker_socket_proxy - the new sidecars
|
||||
# docker_socket_proxy - the sidecar
|
||||
# 10.0.0.0/8 - the swarm's typical overlay subnet (defensive: covers
|
||||
# any IP-direct call that bypasses DNS)
|
||||
NO_PROXY: localhost,127.0.0.1,.local,squid,hermes-gateway,hermes-agent,brencher-state-proxy,docker_socket_proxy,10.0.0.0/8
|
||||
no_proxy: localhost,127.0.0.1,.local,squid,hermes-gateway,hermes-agent,brencher-state-proxy,docker_socket_proxy,10.0.0.0/8
|
||||
NO_PROXY: localhost,127.0.0.1,.local,squid,hermes-gateway,hermes-agent,docker_socket_proxy,10.0.0.0/8
|
||||
no_proxy: localhost,127.0.0.1,.local,squid,hermes-gateway,hermes-agent,docker_socket_proxy,10.0.0.0/8
|
||||
depends_on:
|
||||
- squid
|
||||
deploy:
|
||||
@@ -193,42 +193,6 @@ services:
|
||||
delay: 5s
|
||||
max_attempts: 3
|
||||
|
||||
|
||||
brencher-state-proxy:
|
||||
# Path-locked reverse proxy for brencher.rudolf.keenetic.link/state.
|
||||
# Lets hermes-agent reach /state without going through squid (which
|
||||
# can't see inside TLS) and without exposing the rest of brencher.
|
||||
# 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:
|
||||
# hermes_proxy: same as docker_socket_proxy. hermes-gateway is
|
||||
# already on this overlay, so DNS works. Egress is allowed despite
|
||||
# the `internal: true` flag (which only blocks external ingress,
|
||||
# not outbound traffic). The sidecar's upstream
|
||||
# proxy_pass https://brencher.rudolf.keenetic.link/state is a
|
||||
# public-internet HTTPS call, not a service-name lookup, so
|
||||
# nginx_ingress membership is not required.
|
||||
- hermes_proxy
|
||||
configs:
|
||||
- source: brencher_state_proxy_conf
|
||||
target: /etc/nginx/conf.d/brencher-state-proxy.conf
|
||||
deploy:
|
||||
mode: replicated
|
||||
replicas: 1
|
||||
placement:
|
||||
constraints:
|
||||
- node.hostname == odroid # must run where the secret is mounted (and where the public ingress routes back to)
|
||||
restart_policy:
|
||||
condition: on-failure
|
||||
delay: 5s
|
||||
max_attempts: 3
|
||||
|
||||
networks:
|
||||
hermes_proxy:
|
||||
driver: overlay
|
||||
@@ -247,8 +211,6 @@ configs:
|
||||
file: ./squid.conf
|
||||
nginx_hermes_conf:
|
||||
file: ./nginx-hermes.conf
|
||||
brencher_state_proxy_conf:
|
||||
file: ./brencher-state-proxy.conf
|
||||
|
||||
volumes:
|
||||
squid_etc:
|
||||
|
||||
Reference in New Issue
Block a user