V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
YuxiangLuo
V2EX  ›  HAProxy

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

  •  
  •   YuxiangLuo · 2020-08-11 11:03:39 +08:00 · 2154 次点击
    这是一个创建于 1325 天前的主题,其中的信息可能已经有所发展或是发生改变。

    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
    

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

    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5880 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 02:13 · PVG 10:13 · LAX 19:13 · JFK 22:13
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.