gpt4 book ai didi

linux - 使用单个请求获取 haproxy 两次日志

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:17:22 28 4
gpt4 key购买 nike

我已经配置了三个应用服务器的haproxy

haproxy.cfg:

global
log 127.0.0.1 local2
maxconn 10000

defaults
log global
log-format {"type":"haproxy","timestamp":%Ts,"http_status":%ST,"http_request":"%r","remote_addr":"%ci","bytes_read":%B,"upstream_addr":"%si","backend_name":"%b","retries":%rc,"bytes_uploaded":%U,"upstream_response_time":"%Tr","upstream_connect_time":"%Tc","session_duration":"%Tt","termination_state":"%ts"}
mode http
option httplog
option forwardfor
option httpclose
option accept-invalid-http-request
option dontlognull
option redispatch
retries 1
timeout http-request 40s
timeout connect 40s
timeout client 40s
timeout server 40s

userlist UsersAuth
user viz-status insecure-password VIZ-STATUS

frontend hap-LB
bind *:80
log global
http-request set-header X-Forwarded-Port %[dst_port]
http-request set-header X-Forwarded-Proto https if { ssl_fc }
http-request set-header X-Forwarded-Host %[req.hdr(Host)]
default_backend nginx-nodes
frontend sm-viz
bind *:8008
default_backend sm-viz

backend nginx-nodes
stats enable
stats hide-version
stats uri /hap-status
stats realm Haproxy\ Statistics
stats auth hap-status:HAP-STATUS
balance roundrobin
# option httpchk /feeds/hostname
server dev-01 10.0.0.1:80 #check
server dev-02 10.0.0.2:80 #check
server dev-03 10.0.0.3:80 #check

backend sm-viz
acl AuthOkay http_auth(UsersAuth)
http-request auth realm Swarm-Visualizer if !AuthOkay
balance roundrobin
option httpchk /
server dev-01 10.0.0.1:8081 check
server dev-02 10.0.0.2:8081 check
server dev-03 10.0.0.3:8081 check

配置一切正常,但我们在/var/log/haproxy/haproxy.log 文件中为每个请求获取两次日志

Mar  5 06:37:47 localhost haproxy[1]: 10.0.0.1:34380 [05/Mar/2018:06:37:47.648] hap-LB nginx-nodes/dev-01 0/6/-1/-1/10 503 212 - - SC-- 1/1/0/0/+1 0/0 "GET / HTTP/1.1"
Mar 5 06:37:47 localhost haproxy[1]: 10.0.0.1:34380 [05/Mar/2018:06:37:47.648] hap-LB nginx-nodes/dev-01 0/6/-1/-1/10 503 212 - - SC-- 1/1/0/0/+1 0/0 "GET / HTTP/1.1"
Mar 5 06:37:48 localhost haproxy[1]: 10.0.0.3:34382 [05/Mar/2018:06:37:48.123] hap-LB nginx-nodes/dev-03 0/8/-1/-1/16 503 212 - - SC-- 1/1/0/0/+1 0/0 "GET /favicon.ico HTTP/1.1"
Mar 5 06:37:48 localhost haproxy[1]: 10.0.0.3:34382 [05/Mar/2018:06:37:48.123] hap-LB nginx-nodes/dev-03 0/8/-1/-1/16 503 212 - - SC-- 1/1/0/0/+1 0/0 "GET /favicon.ico HTTP/1.1"

谁能帮我解决这个问题,为什么每个请求要存储两次日志? & 我该如何解决这个问题?

最佳答案

你现在可能已经解决了它,但为了 future googlers 的利益 - 原因是你在 defaults 部分和你的中都有 log 指令前端 部分。如果您从 frontend 部分中删除该行,您应该只会得到一个日志项。

关于linux - 使用单个请求获取 haproxy 两次日志,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49105160/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com