直接使用 haproxy 官方文档的示例配置,出错

2020-08-11 11:03:39 +08:00
 YuxiangLuo

haproxy 版本与官方文档一致:

[root@ecs-J4AOQ haproxy-1.8.25]# haproxy -version
HA-Proxy version 1.8.25 2020/04/02
Copyright 2000-2020 Willy Tarreau <willy@haproxy.org>

测试配置文件报错:

[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

这算是他的问题还是我的问题 (是我的问题,原来这是两个配置文件,我错了)

2184 次点击
所在节点    HAProxy
0 条回复

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/697296

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX