global
    log stdout  format raw  local0  info
    maxconn 2000

    # intermediate configuration
    ssl-default-bind-ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305
    ssl-default-bind-ciphersuites TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256
    ssl-default-bind-options prefer-client-ciphers no-sslv3 no-tlsv10 no-tlsv11 no-tls-tickets

    ssl-default-server-ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305
    ssl-default-server-ciphersuites TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256
    ssl-default-server-options no-sslv3 no-tlsv10 no-tlsv11 no-tls-tickets


defaults
    log global
    unique-id-format %{+X}o\ %ci:%cp_%fi:%fp_%Ts_%rt:%pid
    unique-id-header X-Edge-Request-ID
    option httplog

    timeout connect    3s
    timeout client    10s
    timeout server    10m



frontend tcp_in_31339
    bind *:31339
    mode tcp
    option tcplog
    log global
    default_backend srv_agent_quantum_example_org_31339

backend srv_agent_quantum_example_org_31339
    balance roundrobin
    mode tcp
    option tcp-check
    tcp-check connect
    server srv-0 my-stack_agent:9001 check weight 1

frontend http_in_31337
    bind *:31337
    mode http

    acl is_rule_cadvisor_quantum_example_org_31337_1 hdr(host) -i cadvisor.quantum.example.org
    acl is_rule_cadvisor_quantum_example_org_31337_2 hdr(host) -i cadvisor.quantum.example.org:31337
    use_backend srv_cadvisor_quantum_example_org_31337 if is_rule_cadvisor_quantum_example_org_31337_1 OR is_rule_cadvisor_quantum_example_org_31337_2

    acl is_rule_node-exporter_quantum_example_org_31337_1 hdr(host) -i node-exporter.quantum.example.org
    acl is_rule_node-exporter_quantum_example_org_31337_2 hdr(host) -i node-exporter.quantum.example.org:31337
    acl is_certbot_node-exporter_quantum_example_org_31337 path_beg /.well-known/acme-challenge/
    use_backend certbot_backend if is_certbot_node-exporter_quantum_example_org_31337 is_rule_node-exporter_quantum_example_org_31337_1 OR is_certbot_node-exporter_quantum_example_org_31337 is_rule_node-exporter_quantum_example_org_31337_2
    use_backend srv_node-exporter_quantum_example_org_31337 if is_rule_node-exporter_quantum_example_org_31337_1 OR is_rule_node-exporter_quantum_example_org_31337_2

backend srv_cadvisor_quantum_example_org_31337
    balance roundrobin
    mode http
    option forwardfor
    http-request set-header X-Forwarded-Port %[dst_port]
    http-request add-header X-Forwarded-Proto https if { ssl_fc }
    http-request set-header X-Forwarded-Host %[req.hdr(Host)]
    http-request set-header X-Request-ID %[uuid()]
    server srv-0 my-stack_cadvisor:8080 check weight 1
backend srv_node-exporter_quantum_example_org_31337
    balance roundrobin
    mode http
    option forwardfor
    http-request set-header X-Forwarded-Port %[dst_port]
    http-request add-header X-Forwarded-Proto https if { ssl_fc }
    http-request set-header X-Forwarded-Host %[req.hdr(Host)]
    http-request set-header X-Request-ID %[uuid()]
    server srv-0 my-stack_node-exporter:9100 check weight 1

frontend http_in_443
    bind *:443  ssl crt /etc/easyhaproxy/certs/certbot/ alpn h2,http/1.1 crt /etc/easyhaproxy/certs/haproxy/ alpn h2,http/1.1
    mode http
    redirect prefix https://www.somehost.com.br code 301 if { hdr(host) -i somehost.com.br }
    redirect prefix https://www.somehost.com.br code 301 if { hdr(host) -i somehost.com }
    redirect prefix https://www.somehost.com.br code 301 if { hdr(host) -i www.somehost.com }
    redirect prefix https://www.somehost.com.br code 301 if { hdr(host) -i byjg.ca }
    redirect prefix https://www.somehost.com.br code 301 if { hdr(host) -i www.byjg.ca }

    acl is_rule_node-exporter_quantum_example_org_443_1 hdr(host) -i node-exporter.quantum.example.org
    acl is_rule_node-exporter_quantum_example_org_443_2 hdr(host) -i node-exporter.quantum.example.org:443
    use_backend srv_node-exporter_quantum_example_org_443 if is_rule_node-exporter_quantum_example_org_443_1 OR is_rule_node-exporter_quantum_example_org_443_2

    acl is_rule_www_somehost_com_br_443_1 hdr(host) -i www.somehost.com.br
    acl is_rule_www_somehost_com_br_443_2 hdr(host) -i www.somehost.com.br:443
    use_backend srv_www_somehost_com_br_443 if is_rule_www_somehost_com_br_443_1 OR is_rule_www_somehost_com_br_443_2

backend srv_node-exporter_quantum_example_org_443
    balance roundrobin
    mode http
    option forwardfor
    http-request set-header X-Forwarded-Port %[dst_port]
    http-request add-header X-Forwarded-Proto https if { ssl_fc }
    http-request set-header X-Forwarded-Host %[req.hdr(Host)]
    http-request set-header X-Request-ID %[uuid()]
    server srv-0 my-stack_node-exporter:9100 check weight 1
backend srv_www_somehost_com_br_443
    balance roundrobin
    mode http
    option forwardfor
    http-request set-header X-Forwarded-Port %[dst_port]
    http-request add-header X-Forwarded-Proto https if { ssl_fc }
    http-request set-header X-Forwarded-Host %[req.hdr(Host)]
    http-request set-header X-Request-ID %[uuid()]
    server srv-0 some-service:80 check weight 1

frontend http_in_80
    bind *:80
    mode http
    redirect prefix https://www.somehost.com.br code 301 if { hdr(host) -i somehost.com.br }
    redirect prefix https://www.somehost.com.br code 301 if { hdr(host) -i somehost.com }
    redirect prefix https://www.somehost.com.br code 301 if { hdr(host) -i www.somehost.com }
    redirect prefix https://www.somehost.com.br code 301 if { hdr(host) -i byjg.ca }
    redirect prefix https://www.somehost.com.br code 301 if { hdr(host) -i www.byjg.ca }

    acl is_rule_www_somehost_com_br_80_1 hdr(host) -i www.somehost.com.br
    acl is_rule_www_somehost_com_br_80_2 hdr(host) -i www.somehost.com.br:80
    use_backend srv_www_somehost_com_br_80 if is_rule_www_somehost_com_br_80_1 OR is_rule_www_somehost_com_br_80_2

backend srv_www_somehost_com_br_80
    balance roundrobin
    mode http
    option forwardfor
    http-request set-header X-Forwarded-Port %[dst_port]
    http-request add-header X-Forwarded-Proto https if { ssl_fc }
    http-request set-header X-Forwarded-Host %[req.hdr(Host)]
    http-request set-header X-Request-ID %[uuid()]
    server srv-0 some-service:80 check weight 1

backend certbot_backend
    mode http
    server certbot 127.0.0.1:2080
