四层:
HAproxy:
listen web_prot_http_nodes
bind 192.168.10.10:80
mode tcp
balance roundrobin
server 192.168.10.13:80 send-proxy check inter 3000 fall 3 rise 5
Nginx:
server {
listen 80 proxy_protocol;
server_name www.magege.com;
...
七层:
HAproxy:
option forwardfor #或者option forwardfor x-Forwarded-web_api
listen web_host
bind 80
mode http
log global
balance random
server 192.168.10.14:801 send-proxy check inter 3000 fall 3 rise 5
server 192.168.10.13:801 send-proxy check inter 3000 fall 3 rise 5
web服务器日志格式:
apache:
LogFormat "%{X-Forwarded-For}i %a %l %u %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i"" combinded
tomcat配置:
pattern='%{X-Forwarded-For}i %l %T %t "%r" %s %b "%{User-Agent}i"'/>
nginx配置:
log_format main '"$http_x_forwarded_For" - $remote_user [$time_local] "request" '
'$status $body_bytes_sent "$http_referer"'
'"http_user_agent" ';