Hi,

Le 03/02/2018 à 12:01, garb...@gmx.de a écrit :
I thought about simplifying my haproxy configurations. I will end up with several servers 
running similar setups. The idea is to split the single "haproxy.cfg" into 
several files and combining common parts into separate files and adding differential 
config files where appropriate.
Running "haproxy -f /var/opt/haproxyconfigfiles" works fine already, but not 
all of my config settings are activated. Some seem to get ignored.

Here is a simplified example of what I am doing:

* 001_globalsettings.cfg:
global
     user ...
     group ...

* 002_defaultssettings.cfg:
defaults
     mode http
     ...

* 003_frontend.cfg:
frontend http_front
    bind *:8080
    stats uri /haproxy?stats
    default_backend http_back

* 020_default_stats.cfg:
defaults
     stats enable
     stats hide-version
     stats refresh 30s
     stats show-node
     stats auth admin:password
     stats uri  /haproxystats

I excluded the backend definitions because I don't think they count here. 
Hopefully this example is concise enough to explain what I am doing.

Reading the docs I didn't find information about in which order haproxy reads the config 
files. Is this a random order or is the order I specified by prefixing with 
"001" considered ?

No need to look at the source code (as said below), all the answers are already in the documentation ;-)

About the order, this is explained in the "management" documentation :
http://cbonte.github.io/haproxy-dconv/1.8/management.html
"[...] If <cfgdir> is a directory, all the files (and only files) it contains are added in lexical order (using LC_COLLATE=C) to the list of configuration files to be loaded[...]"


As you can see I have the "stats uri" multiple times, but only "/haproxy?stats" 
is used. This could be explained by a random order.
But "stats auth" is not considered at all and version information is shown dispite of "stats 
hide-versions". This could mean that "defaults" from one file is being overwritten completely 
by a different file.

That's right, a "defaults" section is designed to reset the values of any previous "defaults sections. And those values will only apply to the *following* sections, not to the whole configuration :
http://cbonte.github.io/haproxy-dconv/1.8/configuration.html#4

"[...]A "defaults" section sets default parameters for all other sections following its declaration. Those default parameters are reset by the next "defaults" section.[...]"

It works the same, using one configuration file or many.

Can someone explain to me how haproxy is working ? I would rather not sift 
through the sourcecode ;-)

--
Cyril Bonté

Reply via email to