forked from mtusi2026/mtusi2026lab7
7 — Т2302 — ебедев — на 5
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
HTTP/1.1 403 Forbidden
|
||||
Content-Type: text/plain
|
||||
Cache-Control: no-store
|
||||
Connection: close
|
||||
|
||||
identity is not allowed for this endpoint
|
||||
@@ -0,0 +1,36 @@
|
||||
# mTLS-шлюз Loki (Loki в namespace этого контейнера слушает только 127.0.0.1:3101).
|
||||
# Least privilege по identity: otel-collector — только запись POST /otlp/v1/logs; grafana — только
|
||||
# чтение /loki/api/v1/* (без push/delete); prometheus — GET /metrics. Остальное (в т.ч. rogue того же CA) — 403.
|
||||
global
|
||||
log stdout format raw local0 notice
|
||||
maxconn 1024
|
||||
ssl-default-bind-options ssl-min-ver TLSv1.2 no-tls-tickets
|
||||
stats socket /tmp/haproxy.sock mode 600 level admin
|
||||
|
||||
defaults
|
||||
mode http
|
||||
log global
|
||||
option httplog
|
||||
option dontlognull
|
||||
timeout connect 1s
|
||||
timeout client 60s
|
||||
timeout server 60s
|
||||
timeout http-request 10s
|
||||
timeout http-keep-alive 30s
|
||||
# Отказ в доступе — 403 с причиной (без деталей сертификата).
|
||||
errorfile 403 /usr/local/etc/haproxy/403.http
|
||||
|
||||
frontend loki
|
||||
bind :3100 ssl crt /run/tls/self/tls.pem ca-file /run/tls/trust/ca.crt crl-file /run/tls/trust/crl.pem verify required alpn http/1.1
|
||||
acl id_collector ssl_c_s_dn(CN) -m str otel-collector
|
||||
acl id_grafana ssl_c_s_dn(CN) -m str grafana
|
||||
acl id_prom ssl_c_s_dn(CN) -m str prometheus
|
||||
acl write_api path_beg /loki/api/v1/push /loki/api/v1/delete /loki/api/v1/rules /api/
|
||||
http-request allow if id_collector METH_POST { path /otlp/v1/logs }
|
||||
http-request allow if id_grafana { path_beg /loki/api/v1/ } !write_api
|
||||
http-request allow if id_prom METH_GET { path /metrics }
|
||||
http-request deny deny_status 403
|
||||
default_backend loki
|
||||
|
||||
backend loki
|
||||
server l 127.0.0.1:3101
|
||||
@@ -0,0 +1,48 @@
|
||||
# mTLS-шлюз OTel Collector (сайдкар: Collector работает в сетевом namespace этого контейнера и слушает
|
||||
# ТОЛЬКО 127.0.0.1 — открытый hop есть лишь на loopback внутри namespace).
|
||||
# :4318 OTLP/HTTP ingest — только identity api и worker (CN сертификата нашего CA, не отозван по CRL);
|
||||
# identity передаётся Collector в X-Client-Identity (клиентское значение затирается): Collector
|
||||
# подменяет service.name по identity → worker не может отправлять данные от имени API.
|
||||
# :8888 self-метрики Collector — только identity prometheus, GET /metrics.
|
||||
# HAProxy 3.0 не умеет выбирать по SAN, поэтому allowlist — по CN (pki.py: CN = имя identity).
|
||||
global
|
||||
log stdout format raw local0 notice
|
||||
maxconn 1024
|
||||
ssl-default-bind-options ssl-min-ver TLSv1.2 no-tls-tickets
|
||||
stats socket /tmp/haproxy.sock mode 600 level admin
|
||||
|
||||
defaults
|
||||
mode http
|
||||
log global
|
||||
option httplog
|
||||
option dontlognull
|
||||
timeout connect 1s
|
||||
timeout client 60s
|
||||
timeout server 60s
|
||||
timeout http-request 10s
|
||||
timeout http-keep-alive 30s
|
||||
# Отказ в доступе — 403 с причиной (без деталей сертификата).
|
||||
errorfile 403 /usr/local/etc/haproxy/403.http
|
||||
|
||||
frontend otlp
|
||||
bind :4318 ssl crt /run/tls/self/tls.pem ca-file /run/tls/trust/ca.crt crl-file /run/tls/trust/crl.pem verify required alpn http/1.1
|
||||
acl id_api ssl_c_s_dn(CN) -m str api
|
||||
acl id_worker ssl_c_s_dn(CN) -m str worker
|
||||
acl otlp_path path /v1/traces /v1/metrics /v1/logs
|
||||
http-request del-header X-Client-Identity
|
||||
http-request deny deny_status 403 unless id_api or id_worker
|
||||
http-request deny deny_status 403 unless METH_POST otlp_path
|
||||
http-request deny deny_status 413 if { req.hdr_val(content-length) gt 8388608 }
|
||||
http-request set-header X-Client-Identity %[ssl_c_s_dn(CN)]
|
||||
default_backend collector
|
||||
|
||||
backend collector
|
||||
server c 127.0.0.1:14318
|
||||
|
||||
frontend selfmetrics
|
||||
bind :8888 ssl crt /run/tls/self/tls.pem ca-file /run/tls/trust/ca.crt crl-file /run/tls/trust/crl.pem verify required alpn http/1.1
|
||||
http-request deny deny_status 403 unless { ssl_c_s_dn(CN) -m str prometheus } METH_GET { path /metrics }
|
||||
default_backend collector_metrics
|
||||
|
||||
backend collector_metrics
|
||||
server m 127.0.0.1:18888
|
||||
@@ -0,0 +1,36 @@
|
||||
# mTLS-шлюз Prometheus (Prometheus в namespace этого контейнера слушает только 127.0.0.1:9091).
|
||||
# otel-collector — только OTLP-запись; tempo — только remote write (метрики metrics-generator);
|
||||
# grafana — только чтение /api/v1/* (без admin/записи и remote read). Остальное — 403.
|
||||
global
|
||||
log stdout format raw local0 notice
|
||||
maxconn 1024
|
||||
ssl-default-bind-options ssl-min-ver TLSv1.2 no-tls-tickets
|
||||
stats socket /tmp/haproxy.sock mode 600 level admin
|
||||
|
||||
defaults
|
||||
mode http
|
||||
log global
|
||||
option httplog
|
||||
option dontlognull
|
||||
timeout connect 1s
|
||||
timeout client 60s
|
||||
timeout server 60s
|
||||
timeout http-request 10s
|
||||
timeout http-keep-alive 30s
|
||||
# Отказ в доступе — 403 с причиной (без деталей сертификата).
|
||||
errorfile 403 /usr/local/etc/haproxy/403.http
|
||||
|
||||
frontend prometheus
|
||||
bind :9090 ssl crt /run/tls/self/tls.pem ca-file /run/tls/trust/ca.crt crl-file /run/tls/trust/crl.pem verify required alpn http/1.1
|
||||
acl id_collector ssl_c_s_dn(CN) -m str otel-collector
|
||||
acl id_tempo ssl_c_s_dn(CN) -m str tempo
|
||||
acl id_grafana ssl_c_s_dn(CN) -m str grafana
|
||||
acl write_api path_beg /api/v1/admin /api/v1/write /api/v1/otlp /api/v1/read
|
||||
http-request allow if id_collector METH_POST { path /api/v1/otlp/v1/metrics }
|
||||
http-request allow if id_tempo METH_POST { path /api/v1/write }
|
||||
http-request allow if id_grafana { path_beg /api/v1/ } !write_api
|
||||
http-request deny deny_status 403
|
||||
default_backend prometheus
|
||||
|
||||
backend prometheus
|
||||
server p 127.0.0.1:9091
|
||||
@@ -0,0 +1,41 @@
|
||||
# mTLS-шлюз Tempo (Tempo в namespace этого контейнера: HTTP 127.0.0.1:3201, OTLP 127.0.0.1:4319).
|
||||
# otel-collector — только POST /v1/traces (:4318); grafana — только чтение /api/* (без overrides);
|
||||
# prometheus — GET /metrics.
|
||||
global
|
||||
log stdout format raw local0 notice
|
||||
maxconn 1024
|
||||
ssl-default-bind-options ssl-min-ver TLSv1.2 no-tls-tickets
|
||||
stats socket /tmp/haproxy.sock mode 600 level admin
|
||||
|
||||
defaults
|
||||
mode http
|
||||
log global
|
||||
option httplog
|
||||
option dontlognull
|
||||
timeout connect 1s
|
||||
timeout client 60s
|
||||
timeout server 60s
|
||||
timeout http-request 10s
|
||||
timeout http-keep-alive 30s
|
||||
# Отказ в доступе — 403 с причиной (без деталей сертификата).
|
||||
errorfile 403 /usr/local/etc/haproxy/403.http
|
||||
|
||||
frontend tempo_otlp
|
||||
bind :4318 ssl crt /run/tls/self/tls.pem ca-file /run/tls/trust/ca.crt crl-file /run/tls/trust/crl.pem verify required alpn http/1.1
|
||||
http-request deny deny_status 403 unless { ssl_c_s_dn(CN) -m str otel-collector } METH_POST { path /v1/traces }
|
||||
default_backend tempo_otlp
|
||||
|
||||
backend tempo_otlp
|
||||
server t 127.0.0.1:4319
|
||||
|
||||
frontend tempo_api
|
||||
bind :3200 ssl crt /run/tls/self/tls.pem ca-file /run/tls/trust/ca.crt crl-file /run/tls/trust/crl.pem verify required alpn http/1.1
|
||||
acl id_grafana ssl_c_s_dn(CN) -m str grafana
|
||||
acl id_prom ssl_c_s_dn(CN) -m str prometheus
|
||||
http-request allow if id_grafana { path_beg /api/ } !{ path_beg /api/overrides }
|
||||
http-request allow if id_prom METH_GET { path /metrics }
|
||||
http-request deny deny_status 403
|
||||
default_backend tempo_api
|
||||
|
||||
backend tempo_api
|
||||
server t 127.0.0.1:3201
|
||||
Reference in New Issue
Block a user