我目前有一个HAproxy负载平衡器设置与2个后端,共3个网站。其中一个网站需要额外的服务器(一个新后端,后端#3),但其他网站不需要使用这个后端。有办法这样做吗?遗憾的是,我无法使用文档来解决这个问题。配置添加。新的后端将是.77。谢谢!
global
log /dev/log local0
log /dev/log local1 notice
chroot /var/lib/haproxy
stats socket /run/haproxy/admin.sock mode 660 level admin
stats timeout 30s
user haproxy
group haproxy
maxconn 2000
daemon
# Default SSL material locations
ca-base /etc/ssl/certs
crt-base /etc/ssl/private
# Default ciphers to use on SSL-enabled listening sockets.
# For more information, see ciphers(1SSL). This list is from:
# https://hynek.me/articles/hardening-your-web-servers-ssl-ciphers/
ssl-default-bind-ciphers ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AESGCM:RSA+AES:RSA+3DES:!aNULL:!MD5:!DSS
ssl-default-bind-options no-sslv3
# use 7 of 8 cores, bind stats to the 7th. We want one core for OS and stuff :)
nbproc 7
cpu-map 1 1
cpu-map 2 2
cpu-map 3 3
cpu-map 4 4
cpu-map 5 5
cpu-map 6 6
cpu-map 7 7
stats bind-process 7
defaults
log global
mode http
option httplog
option dontlognull
option forwardfor
option http-server-close
timeout connect 5000
timeout client 50000
timeout server 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 192.168.3.78:1936
stats enable
stats uri /
frontend www-http
bind 1.2.3.4:80
bind 192.168.3.78:80
reqadd X-Forwarded-Proto:\ http
bind-process 1
default_backend www-backend
frontend www-https
bind 1.2.3.4:443 ssl crt /etc/ssl/private/1.full-pem crt /etc/ssl/private/2.full-pem crt /etc/ssl/private/3.full-pem
reqadd X-Forwarded-Proto:\ https
option forwardfor
bind-process 2 3 4 5 6
default_backend www-backend
backend www-backend
redirect scheme https if !{ ssl_fc }
cookie SERVERID insert indirect nocache
server www-1 192.168.3.75:80 check cookie www-1
server www-2 192.168.3.74:80 check cookie www-2
发布于 2016-12-07 21:30:19
关于“后端”一词的注意:您在问题中使用它来描述将被转发请求的服务。为了避免混淆,我将在这里使用server,backend将是一组server (以匹配HAProxy术语)。
您需要两个backend块,一个带两个server,另一个带三个。在frontend中,使用主机名选择正确的主机名:
frontend www-http
[...]
acl host_website3 hdr(host) -i website3.com # match the new website
use_backend www-backend-with3 if host_website3 # send it to the correct backend
default_backend www-backend
backend www-backend
redirect scheme https if !{ ssl_fc }
cookie SERVERID insert indirect nocache
server www-1 192.168.3.75:80 check cookie www-1
server www-2 192.168.3.74:80 check cookie www-2
backend www-backend-with3 # new backend here
redirect scheme https if !{ ssl_fc }
cookie SERVERID insert indirect nocache
server www-1 192.168.3.75:80 check cookie www-1
server www-2 192.168.3.74:80 check cookie www-2
server www-3 192.168.3.77:80 check cookie www-3 # with a new server herehttps://stackoverflow.com/questions/41025910
复制相似问题