Files
k3s/hermes_squid/stack-compose.yml
c3b7128006 hermes_squid: open docker_socket_proxy to full read-only scope (#4)
Flip CONTAINERS/IMAGES/NETWORKS/VOLUMES/SERVICES/TASKS/NODES from 0 to 1 so hermes-agent can inspect running stacks (read container logs, enumerate swarm services) without going through each node's shell.

POST stays 0 — no container creation, no image builds, no exec into running containers. Anything that mutates state remains blocked at the proxy level.

---------

Co-authored-by: admin <rudolfss13@gmail.com>
Co-authored-by: hermes <hermes@rudolf.keenetic.link>
Reviewed-on: http://192.168.1.96/admin/ansible/pulls/4
Co-authored-by: hermes <rudolfss13+hermes@gmail.com>
2026-08-30 00:09:56 +02:00

259 lines
8.0 KiB
YAML

version: "3.9"
services:
squid:
image: ubuntu/squid:latest
hostname: squid
networks:
- hermes_proxy
- squid_egress
ports:
- target: 3128
published: 3128
protocol: tcp
configs:
- source: squid_conf
target: /etc/squid/squid.conf
volumes:
- squid_logs:/var/log/squid
environment:
TZ: UTC
deploy:
placement:
constraints:
- node.hostname != xu4
replicas: 1
resources:
limits:
memory: 128M
pids: 256
reservations:
memory: 128M
restart_policy:
condition: on-failure
sarg:
build: .
image: registry.rudolf.keenetic.link/sarg:${version}
hostname: sarg
networks:
- admin
ports:
- target: 80
published: 8090
protocol: tcp
volumes:
- squid_logs:/var/log/squid:ro
- squid_reports:/www
deploy:
placement:
constraints:
- node.hostname != xu4
replicas: 1
resources:
limits:
memory: 128M
pids: 128
reservations:
memory: 128M
restart_policy:
condition: on-failure
hermes-gateway:
image: nousresearch/hermes-agent:v2026.8.3
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.
- hermes_proxy
volumes:
- hermes_gateway_data:/opt/data
environment:
HERMES_DASHBOARD: "1"
HERMES_DASHBOARD_HOST: "0.0.0.0"
HERMES_DASHBOARD_BASIC_AUTH_USERNAME: admin
HERMES_DASHBOARD_BASIC_AUTH_PASSWORD: admin
HERMES_AGENT_URL: http://hermes-agent:8000
HERMES_YOLO_MODE: "1"
# TELEGRAM_REQUIRE_MENTION: "true"
# TELEGRAM_OBSERVE_UNMENTIONED_GROUP_MESSAGES: "true"
HTTP_PROXY: http://squid:3128
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).
# 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
# 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
depends_on:
- squid
deploy:
placement:
constraints:
- node.hostname != xu4
replicas: 1
resources:
limits:
memory: 1G
pids: 512
reservations:
memory: 1G
restart_policy:
condition: on-failure
hermes-ui:
image: nginx:alpine
hostname: hermes-ui
networks:
- hermes_proxy
- default
ports:
- target: 8087
published: 8088
protocol: tcp
configs:
- source: nginx_hermes_conf
target: /etc/nginx/conf.d/default.conf
depends_on:
- hermes-gateway
deploy:
placement:
constraints:
- node.hostname != xu4
replicas: 1
resources:
limits:
memory: 32M
pids: 128
reservations:
memory: 32M
restart_policy:
condition: on-failure
docker_socket_proxy:
# tecnativa/docker-socket-proxy: HAProxy in front of the host Docker socket,
# filtering the Docker REST API by URL prefix. Inlined here so the proxy
# deploys + tears down with the rest of hermes_infra.
# https://github.com/Tecnativa/docker-socket-proxy
image: tecnativa/docker-socket-proxy:latest
hostname: docker_socket_proxy
privileged: true # required for /var/run/docker.sock bind in SELinux/AppArmor contexts
volumes:
- /var/run/docker.sock:/var/run/docker.sock
networks:
# hermes_proxy: hermes-gateway already lives here, so DNS resolves
# the sidecar by name. Despite the overlay's `internal: true` flag,
# egress to external IPs is not blocked -- the flag only denies
# external ingress to the overlay, not outbound traffic. The sidecar
# needs egress to reach any external resource (none today, but the
# same overlay can host future sidecars that do).
- hermes_proxy
environment:
BIND_CONFIG: ":2375"
LOG_LEVEL: "info"
# Default policy matches the image defaults: read-only PING / EVENTS / VERSION.
# Anything else (POST, CONTAINERS, IMAGES, SERVICES, ...) must be explicitly
# toggled to 1 by a consumer that has a reason to need it. NEVER widen the
# scope from a generic change like this one.
CONTAINERS: 1
IMAGES: 1
NETWORKS: 1
VOLUMES: 1
SERVICES: 1
TASKS: 1
NODES: 1
POST: 0
ports:
- target: 2375
published: 2375
protocol: tcp
mode: host # bind on the swarm manager (odroid), not on the ingress
deploy:
mode: replicated
replicas: 1
placement:
constraints:
- node.hostname == odroid # the swarm manager; socket is local
restart_policy:
condition: on-failure
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
attachable: true
internal: true
squid_egress:
driver: overlay
admin:
driver: overlay
attachable: true
nginx_ingress:
external: true
configs:
squid_conf:
file: ./squid.conf
nginx_hermes_conf:
file: ./nginx-hermes.conf
brencher_state_proxy_conf:
file: ./brencher-state-proxy.conf
volumes:
squid_etc:
squid_logs:
squid_reports:
hermes_gateway_data:
hermes_agent_data: