forked from mtusi2026/mtusi2026lab7
86 lines
5.3 KiB
INI
86 lines
5.3 KiB
INI
global
|
|
maxconn 16
|
|
tune.bufsize 131072
|
|
nbthread 1
|
|
hard-stop-after 2s
|
|
ssl-default-bind-options ssl-min-ver TLSv1.2 no-tls-tickets
|
|
ssl-default-server-options ssl-min-ver TLSv1.2
|
|
defaults
|
|
mode tcp
|
|
timeout connect 2s
|
|
timeout client 30s
|
|
timeout server 30s
|
|
resolvers docker
|
|
nameserver dns 127.0.0.11:53
|
|
resolve_retries 3
|
|
timeout resolve 1s
|
|
timeout retry 1s
|
|
hold valid 1s
|
|
|
|
listen ingest
|
|
mode http
|
|
bind :5080 ssl crt /pki/server.pem ca-file /pki/ca.crt crl-file /pki/ca.crl verify required
|
|
tcp-request content reject unless { ssl_c_s_dn(CN) -m str collector operator }
|
|
acl collector ssl_c_s_dn(CN) -m str collector
|
|
acl ingest path /api/default/v1/logs /api/default/v1/metrics /api/default/v1/traces
|
|
acl post method POST
|
|
http-request deny status 403 if collector !ingest
|
|
http-request deny status 403 if collector !post
|
|
server local 127.0.0.1:15080
|
|
|
|
listen query
|
|
mode http
|
|
bind :5082 ssl crt /pki/server.pem ca-file /pki/ca.crt crl-file /pki/ca.crl verify required
|
|
tcp-request content reject unless { ssl_c_s_dn(CN) -m str grafana operator }
|
|
timeout client 10s
|
|
timeout server 10s
|
|
timeout http-request 3s
|
|
timeout http-keep-alive 1s
|
|
timeout queue 1s
|
|
acl grafana ssl_c_s_dn(CN) -m str grafana
|
|
acl read_method method GET
|
|
acl search_method method POST
|
|
acl search_path path -m str /api/default/_search
|
|
acl read_path path -m str /api/organizations /api/default/streams
|
|
acl read_path path_reg ^/api/default/streams/[A-Za-z0-9_]+/schema$
|
|
acl read_path path -m str /api/default/messenger/_values
|
|
acl read_path path_reg ^/api/default/prometheus/api/v1/(query|query_range|labels|series|metadata)$
|
|
acl read_path path_reg ^/api/default/prometheus/api/v1/label/[A-Za-z0-9_]+/values$
|
|
http-request deny deny_status 403 unless !grafana or read_method read_path or search_method search_path
|
|
http-request wait-for-body time 2s if grafana search_method search_path
|
|
http-request deny deny_status 413 if grafana search_method search_path { req.body_len gt 65536 }
|
|
http-request set-var(txn.rows) req.body,json_query('$.query.size','int') if grafana search_method search_path
|
|
http-request set-var(txn.begin) req.body,json_query('$.query.start_time','int') if grafana search_method search_path
|
|
http-request set-var(txn.end) req.body,json_query('$.query.end_time','int') if grafana search_method search_path
|
|
http-request set-var(txn.window) var(txn.end),sub(txn.begin) if grafana search_method search_path
|
|
# Native plugin supplementary histogram omits size; preserve native default and explicit zero.
|
|
acl search_size_present req.body,json_query('$.query.size') -m found
|
|
http-request deny deny_status 400 if grafana search_method search_path search_size_present !{ var(txn.rows) -m int 0:1000 }
|
|
http-request deny deny_status 400 if grafana search_method search_path !{ var(txn.begin) -m int gt 0 }
|
|
http-request deny deny_status 400 if grafana search_method search_path !{ var(txn.window) -m int 1:3600000000 }
|
|
acl duplicate_query query,url_dec -m reg (^|&)size=[^&]*(&[^&]*)*&size= (^|&)start_time=[^&]*(&[^&]*)*&start_time= (^|&)end_time=[^&]*(&[^&]*)*&end_time= (^|&)start=[^&]*(&[^&]*)*&start= (^|&)end=[^&]*(&[^&]*)*&end= (^|&)query=[^&]*(&[^&]*)*&query=
|
|
http-request deny deny_status 400 if grafana read_method duplicate_query
|
|
acl values_path path -m str /api/default/messenger/_values
|
|
http-request set-var(txn.rows) url_param(size),add(0) if grafana read_method values_path
|
|
http-request set-var(txn.begin) url_param(start_time),add(0) if grafana read_method values_path
|
|
http-request set-var(txn.end) url_param(end_time),add(0) if grafana read_method values_path
|
|
http-request set-var(txn.window) var(txn.end),sub(txn.begin) if grafana read_method values_path
|
|
http-request deny deny_status 400 if grafana read_method values_path !{ var(txn.rows) -m int 1:1000 }
|
|
http-request deny deny_status 400 if grafana read_method values_path !{ var(txn.window) -m int 1:3600000000 }
|
|
acl range_path path -m str /api/default/prometheus/api/v1/query_range
|
|
http-request set-var(txn.begin_s) url_param(start),field(1,.),add(0) if grafana read_method range_path
|
|
http-request set-var(txn.end_s) url_param(end),field(1,.),add(0) if grafana read_method range_path
|
|
http-request set-var(txn.window_s) var(txn.end_s),sub(txn.begin_s) if grafana read_method range_path
|
|
http-request deny deny_status 400 if grafana read_method range_path !{ var(txn.begin_s) -m int gt 0 }
|
|
http-request deny deny_status 400 if grafana read_method range_path !{ var(txn.window_s) -m int 1:3599 }
|
|
# Recognized native OO framing only; not a streaming/decompression or SQL work cap.
|
|
# Adapted from reviewed lab6 8aa801e8, retaining lab7's mTLS identities and 8MiB budget.
|
|
http-request set-header Accept-Encoding identity
|
|
acl response_encoded res.fhdr_cnt(Content-Encoding) gt 0
|
|
acl response_transfer_encoded res.fhdr_cnt(Transfer-Encoding) gt 0
|
|
acl response_length_single res.fhdr_cnt(Content-Length) eq 1
|
|
acl response_length_canonical res.fhdr(Content-Length) -m reg ^(0|[1-9][0-9]{0,6})$
|
|
acl response_length_excessive res.fhdr(Content-Length) -m int gt 8388608
|
|
http-response return status 502 content-type application/json string '{"error":"query_response_boundary"}' if response_encoded or response_transfer_encoded or !response_length_single or !response_length_canonical or response_length_excessive
|
|
server local 127.0.0.1:15080
|