I know that I can reload haproxy from a shell command (I use service haproxy reload).

I also am using the stats socket to enable and disable servers when doing maintenance on them. I also have worked with the stats webserver, although it's disabled at the moment.

Is it possible to use the stats socket to force a reload, too? (The use case is to let a person without admin privs on the server add a new https certificate to the network folder where I am storing them, and use reload to make sure haproxy sees it.)

My config, sanitized:

        log /dev/log    local0
        log /dev/log    local1 notice
        chroot /var/lib/haproxy
        stats socket /run/haproxy/admin.sock mode 660 level admin
        stats socket ipv4@ level admin
        stats timeout 30s
        user haproxy
        group haproxy
        tune.ssl.default-dh-param 2048

        # Default SSL material locations
        ca-base /etc/ssl/certs
        crt-base /etc/ssl/private

        # Default ciphers to use on SSL-enabled listening sockets.
        # For more information, see ciphers(1SSL). This list is from:
        #  https://hynek.me/articles/hardening-your-web-servers-ssl-ciphers/
        ssl-default-bind-options no-sslv3

        log     global
        mode    http
        option  httplog
        option  dontlognull
        timeout connect 50000
        timeout client  500000
        timeout server  500000
        errorfile 400 /etc/haproxy/errors/400.http
        errorfile 403 /etc/haproxy/errors/403.http
        errorfile 408 /etc/haproxy/errors/408.http
        errorfile 500 /etc/haproxy/errors/500.http
        errorfile 502 /etc/haproxy/errors/502.http
        errorfile 503 /etc/haproxy/errors/503.http
        errorfile 504 /etc/haproxy/errors/504.http

frontend http-in
        acl host_onedomain hdr(host) -i -m end onedomain.com
        ;;; additional, similar domain acls omitted
        acl ip_172_16_55_96 dst

        http-request set-header HTTPS ON if { ssl_fc }

        bind *:80
        bind *:443 ssl crt /media/windowsshare/winserver/ssl/pem/
        use_backend staging if host_staging
        use_backend production if host_production
        default_backend staging

backend staging
        server SERVER1 maxconn 64
        server SERVER2 maxconn 64

backend production
        server SERVER1 maxconn 64
        server SERVER2 maxconn 64

listen stats *:1936
        stats enable
        stats uri /
        stats hide-version
        stats auth sysadmin:password
        stats admin if TRUE

In a word, no.

You can't reload the whole process from the socket, and all details about using the admin sockets are listed under section 9.2 Unix Socket commands of the management docs.

  • 1
    This makes sense, considering that "reloading" HAProxy actually starts a new haproxy process which then tells the old process to hand over control of the listening sockets and shut itself down once its existing sessions finish. – Michael - sqlbot Nov 26 '15 at 1:48
  • 1
    My final solution was to add a crontab entry that checks the folder's last modified date against /run/haproxy.pid. If the folder is newer, it reloads haproxy. This achieves the effect that I needed. – Ross Presser Nov 30 '15 at 21:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.