0

How to make haproxy k8s pod read scss/images/icons files inside assets folder referenced in a index.htm file?

I have a maintenance page whose text info is coming perfectly. We used maintenance page when our backend application is down for reason and we get 503 error message.

Below is the haproxy.cfg file

global
  log 127.0.0.1   local1
  maxconn 4096
  ssl-default-bind-ciphers TLS13-AES-256-GCM-SHA384:TLS13-AES-128-GCM-SHA256:TLS13-CHACHA20-POLY1305-SHA256:EECDH+AESGCM:EECDH+CHACHA20
  ssl-default-bind-options no-sslv3 no-tlsv10 no-tlsv11

defaults
  mode http
  maxconn 2048


frontend e-store-app
  bind *:80
  bind *:443 ssl crt /usr/local/etc/haproxy/e-store-app.pem
  errorfile 503 /usr/local/etc/haproxy/errors/index.html
  # 16000000 seconds is a bit more than 6 months
  http-response set-header Strict-Transport-Security "max-age=16000000; includeSubDomains; preload;"
  redirect scheme https if !{ ssl_fc }
  mode http
  timeout connect 5s
  timeout client 5s
  timeout server 5s
  default_backend e-store-app

backend e-store-app
  redirect scheme https if !{ ssl_fc }
  server e-store-app e-store-app:8080  check inter 5s rise 2 fall 3
  compression algo gzip
  compression type text/css text/html text/javascript application/javascript text/plain text/xml application/json

Haproxy Deployment.

apiVersion: apps/v1
kind: Deployment
metadata:
 name: test-haproxy
spec:
 replicas: 1
 selector:
   matchLabels:
     app: test-haproxy
 template:
   metadata:
     labels:
       app: test-haproxy
   spec:
     containers:
       - name: test-haproxy
         image: haproxy:1.7
         imagePullPolicy: Always
         ports:
           - containerPort: 80
           - containerPort: 443
  
           
         volumeMounts:
           - mountPath: "/usr/local/etc/haproxy"
             name: haproxy-config
     volumes:
       - name: haproxy-config
         hostPath:
           path: /root/kubernetes/dev-cluster-manifest/haproxy


Text message in the index.html is coming as expected but not the scss/images referenced in the index.html file inside the errors/assests directory.

Is something wrong we are doing in the haproxy config file? how to make haproxy read images,icons, available inside errors/assest directory and referenced inside index.html file.

James Taylor
  • 355
  • 1
  • 4
  • 13

1 Answers1

0

As HAProxy is a reverse Proxy and not a web-server, therefore can't you read the assets from the disc via HAProxy.

What you can do is to add all data from the assets to the html file, this could require to increase the tune.bufsize .

Please consider to use a supported HAProxy version like 2.6 or 2.7 as the Deployment shows image: haproxy:1.7 which isn't supported any more from the community see the table on https://www.haproxy.org/

Aleksandar
  • 2,442
  • 3
  • 15
  • 24