sh Ubuntu上的Haproxy 1.6节点服务器平衡器,适用于aws

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sh Ubuntu上的Haproxy 1.6节点服务器平衡器,适用于aws相关的知识,希望对你有一定的参考价值。

frontend localnodes
  bind *:443 ssl crt /home/ubuntu/cert.pem  no-sslv3
  acl secure dst_port eq 443
  mode tcp
  default_backend nodes
       
backend nodes
  mode tcp
  balance roundrobin
  option httpchk GET / HTTP/1.1\r\nHost:localhost
  server web01 127.0.0.1:9090 check
  server web02 127.0.0.1:9091 check
  server web03 127.0.0.1:9092 check
  
global
  log /dev/log    local0
  log /dev/log    local1 notice
  chroot /var/lib/haproxy
  user haproxy
  group haproxy
  daemon
  ssl-default-bind-ciphers  EECDH+ECDSA+AESGCM:EECDH+aRSA+AESGCM:EECDH+ECDSA+SHA384:EECDH+ECDSA+SHA256:EEC$
  ssl-default-bind-options no-sslv3 no-tlsv10
  tune.ssl.default-dh-param 4096
  
defaults
  log     global
  mode    http
  option  httplog
  option  dontlognull
  contimeout 5000
  clitimeout 50000
  srvtimeout 50000
  errorfile 400 /etc/haproxy/errors/400.http
  errorfile 403 /etc/haproxy/errors/403.http
  errorfile 408 /etc/haproxy/errors/408.http
  errorfile 500 /etc/haproxy/errors/500.http
  errorfile 502 /etc/haproxy/errors/502.http
  errorfile 503 /etc/haproxy/errors/503.http
  errorfile 504 /etc/haproxy/errors/504.http
 
listen stats
  bind *:1936
  mode http
  balance
  timeout client 5000
  timeout connect 4000
  timeout server 30000
  #This is the virtual URL to access the stats page
  stats uri /haproxy_stats
  stats auth admin:password
  #This allows you to take down and bring up back end servers.
  #This will produce an error on older versions of HAProxy.
  stats admin if TRUE
 


        
sudo add-apt-repository ppa:vbernat/haproxy-1.6
sudo apt-get update
sudo apt-get install haproxy

# restart service
sudo service haproxy restart

# configuration file
sudo nano /etc/haproxy/haproxy.cfg

# check configuration file for alerts
haproxy -c -V -f /etc/haproxy/haproxy.cfg

# don't forget to remove any ubuntu port forwarding (usually in defined in /etc/rc.local)

# add node server to autoloading:
crontab -e
# add: 
@reboot PORT=9090 forever start /home/ubuntu/app/index.js
@reboot PORT=9091 forever start /home/ubuntu/app/index.js
@reboot PORT=9092 forever start /home/ubuntu/app/index.js


以上是关于sh Ubuntu上的Haproxy 1.6节点服务器平衡器,适用于aws的主要内容,如果未能解决你的问题,请参考以下文章

sh Ubuntu 16.04上的Bootstrap Elasticsearch数据节点

反向代理负载均衡系列之Haproxy

haproxy

sh 在Ubuntu中安装SVN 1.6(不要问为什么)

使用HAProxy搭建Web群集

Haproxy+Nginx实现web负载均衡群集