HAProxy frontend not serving html page

21 views Asked by At

I am trying to configure a HAproxy frontend to deliver my HTML page, but it is not working.

/etc/haproxy/haproxy.cfg

global

log         127.0.0.1 local2

chroot      /var/lib/haproxy
pidfile     /var/run/haproxy.pid
maxconn     4000
user        haproxy
group       haproxy
daemon

# turn on stats unix socket
stats socket /var/lib/haproxy/stats

# utilize system-wide crypto-policies
ssl-default-bind-ciphers PROFILE=SYSTEM
ssl-default-server-ciphers PROFILE=SYSTEM


defaults
    mode                    http
    log                     global
    option                  httplog
    option                  dontlognull
    option http-server-close
    option forwardfor       except 127.0.0.0/8
    option                  redispatch
    retries                 3
    timeout http-request    10s
    timeout queue           1m
    timeout connect         10s
    timeout client          1m
    timeout server          1m
    timeout http-keep-alive 10s
    timeout check           10s
    maxconn 

            3000


frontend my_frontend
  bind *:80
  acl is_html_page path -i /your_page.html
  http-request set-path /your_page.html if is_html_page
  acl url_static       path_beg       -i /static /images /javascript /stylesheets
  acl url_static       path_end       -i .jpg .gif .png .css .js
  default_backend my_backend

backend my_backend
  balance roundrobin
  server server1 192.168.252.246:80 check
  server server2 192.168.252.174:80 check

/your-page.html

<html>
        <body>
                <h1>Hello from HAPROXY </h1>
        </body>
</html>

When i perform a curl on localhost:80 on the server itself, i get the following response:

<html><body><h1>400 Bad request</h1>
Your browser sent an invalid request.
</body></html>

Can someone please help me ?

0

There are 0 answers

Related Questions in HAPROXY-FRONTEND