1:stats web
-----------
listen stats # Define a listen section called "stats"
bind :9000 # Listen on localhost:9000
mode http
stats enable # Enable stats page
stats hide-version # Hide HAProxy version
stats realm Haproxy\ Statistics # Title text for popup window
stats uri /haproxy_stats # Stats URI
stats auth Username:Password # Authentication credentials
2:stats socket
-----------
global
# [...]
stats socket /var/run/haproxy/haproxy.sock mode 660 level admin
stats timeout 2m # Wait up to 2 minutes for input
1:修改 Haproxy.conf
-------------------------------
defaults
option http-server-close
option forwardfor
2:httpd.conf 修改
-------------------------------
## LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%{X-Forwarded-For}i %l %u %t \”%r\” %>s %b \”%{Referer}i\” \”%{User-Agent}i\"" combined
<VirtualHost *:80>
ServerName test.cnblog.xyz
ErrorLog "|/usr/sbin/rotatelogs /var/log/httpd/http_error_%Y%m%d.log 86400 480"
CustomLog "|/usr/sbin/rotatelogs /var/log/httpd/http_access_%Y%m%d.log 86400 480" combined
</VirtualHost>
3:nginx.conf 修改
-------------------------------
log_format combined2 ‘$http_x_forwarded_for - $remote_user [$time_local] ‘
‘"$request" $status $body_bytes_sent ‘
‘"$http_referer" "$http_user_agent" ‘;
access_log /var/log/nginx/access.log combined2;
※ TCP ONLY
frontend PortForward
bind *:9100
default_backend Prometheus-S1
backend Prometheus-S1
server Prometheus-S1 114.114.114.114 maxconn 20480
原文:https://www.cnblogs.com/tamatama/p/13272887.html