HAProxy-1.8.20 根据后缀名转发到后端服务器

global
maxconn 100000
chroot /data/soft/haproxy
stats socket /var/lib/haproxy/haproxy.sock mode 600 level admin
uid 1000
gid 1000
daemon
nbproc 2
cpu-map 1 0
cpu-map 2 1
pidfile /usr/local/haproxy/run/haproxy.pid
log 127.0.0.1 local3 info
defaults
  option http-keep-alive
  option  forwardfor # ip地址透传 针对http 协议有效
  maxconn 100000
  mode http
  timeout connect 300000ms
  timeout client  300000ms
  timeout server  300000ms

################   重点配置   ################
frontend web_prot_80
  bind 0.0.0.0:80
  mode http

  acl image_port  path_end -i .jpg 
  acl php_port  path_end -i .php

  use_backend image_nodes if image_port
  use_backend php_nodes if php_port
  default_backend backup_nodes

backend image_nodes 
  server server1  10.10.29.207:80 weight 1 check port 80 inter 3s fall 2 rise 5

backend php_nodes 
  server server2  10.10.4.209:80  weight 1 check port 80 inter 3s fall 2 rise 5

backend backup_nodes 
  server server3  10.10.116.206:80 weight 1 check port 80 inter 3s fall 2 rise 5
原文地址:https://www.cnblogs.com/zhenxing06/p/12775809.html