Problem: My website is loading my .js and .css files as type “text/html”, but only when going through haproxy.
I have a website on Host1, let’s say IP is 192.168.1.10 and that the website is my-website.com. I also have a DNS record for “my-website.com” pointing to my haproxy server, who then sends these requests to Host1.
When I access the website directly, without going through haproxy, like “https://192.168.1.10/loginpage”, everything loads correctly. When I access through https://my-website.com/loginpage", the page doesn’t load fully and when I check the browser tools, I see that the server is serving the .css and .js files as type “text/html”.
I presume I have some misconfiguration on my haproxy. How do I force haproxy to not change or to correctly set the content type headers for each file server by the backend?
Here’s a bit of the configuration of my haproxy file:
frontend fe_my-website.com
mode http
bind :443 ssl crt /etc/haproxy/certs/my-cert.pem alpn h2,http/1.1
bind :80
redirect scheme https code 301 if !{ ssl_fc }
stick-table type ip size 5k expire 10h
stick on src
cookie JSESSIONID prefix
# HSTS (63072000 seconds)
http-response set-header Strict-Transport-Security max-age=63072000
# ACLs for my-website.com
acl acl_my-website hdr(host) -i my-website.com
use_backend be_my-website if acl_my-website
# backends
backend be_my-website
mode http
option httpchk
http-request set-path /loginpage
server my-website.com host_ip:443 check ssl verify none
Thank you for your help.