haproxy 版本与官方文档一致:
[root@ecs-J4AOQ haproxy-1.8.25]# haproxy -version
HA-Proxy version 1.8.25 2020/04/02
Copyright 2000-2020 Willy Tarreau <[email protected]>
测试配置文件报错:
[root@ecs-J4AOQ haproxy-1.8.25]# haproxy -f /etc/haproxy/haproxy.cfg -c
[ALERT] 223/105011 (24317) : parsing [/etc/haproxy/haproxy.cfg:26] : 'maxconn' already specified. Continuing.
[ALERT] 223/105011 (24317) : Parsing [/etc/haproxy/haproxy.cfg:34]: proxy 'http-in' has the same name as frontend 'http-in' declared at /etc/haproxy/haproxy.cfg:14
[ALERT] 223/105011 (24317) : Error(s) found in configuration file : /etc/haproxy/haproxy.cfg
[ALERT] 223/105011 (24317) : Fatal errors found in configuration.
官方文档:
http://cbonte.github.io/haproxy-dconv/1.8/configuration.html#chapter-2.5
我的配置(只把 8000 改成了 8080 ):
[root@ecs-J4AOQ ~]# cat /etc/haproxy/haproxy.cfg
# Simple configuration for an HTTP proxy listening on port 80 on all
# interfaces and forwarding requests to a single backend "servers" with a
# single server "server1" listening on 127.0.0.1:8000
global
daemon
maxconn 256
defaults
mode http
timeout connect 5000ms
timeout client 50000ms
timeout server 50000ms
frontend http-in
bind *:80
default_backend servers
backend servers
server server1 127.0.0.1:8080 maxconn 32
# The same configuration defined with a single listen block. Shorter but
# less expressive, especially in HTTP mode.
global
daemon
maxconn 256
defaults
mode http
timeout connect 5000ms
timeout client 50000ms
timeout server 50000ms
listen http-in
bind *:80
server server1 127.0.0.1:8000 maxconn 32
这算是他的问题还是我的问题 (是我的问题,原来这是两个配置文件,我错了)