首页 > 其他 > 详细

Haproxy 使用

时间:2020-07-09 12:34:10      阅读:59      评论:0      收藏:0      [点我收藏+]

 

设置状态监控页面 
真实ip转发
中继(中转/端口转发)

 


 

设置状态监控页面

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

真实ip转发

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

 

Haproxy 使用

原文:https://www.cnblogs.com/tamatama/p/13272887.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!