I have an haproxy 1.5.18 installed about 10 months ago and the configuration file has not changed. About a month, every now and then going through the proxy results in a CSS or JS fetch having the wrong Content-Type “application/vnd.spring-boot.actuator.v2+json” assigned which causes the page to not load. If I go through directly to the server immediate after that event, the page loads correctly and the CSS and JS client-bundle have the Content-Type set correctly, i.e. “text/css” and “application/javascript” respectively. I have restarted the server to no change.
I thought of putting in a kludge that when the URL ends with .js or .css just modify the Content-Type to the correct one. Any ideas of what to look at?
I assume that your application has something to do with “spring boot actuator” ? That is not haproxy, it doesn’t matter how old the haproxy release is.
You should investigate why this happens on your backend application.
Rewriting the Content-Type with haproxy can be done, but it is not addressing the root cause and as such, it is unclear whether it actually resolve all your issue (I think that is unlikely).
To rewrite Content-Type (a response header) based on the how the path ends (the request URI), you’d have to set a txn variable (a variable that is valid for the entire HTTP transaction), because otherwise you cannot access the URI anymore when sending the response.
I think this approach is a waste of time, but it would probably look something like:
frontend fe
http-request set-var(txn.path) path
backend bk
http-response set-header Content-Type text/css if { txn.path -m end .css }
http-response set-header Content-Type application/javascript if { txn.path -m end .js }
Thanks. I just upgraded to 1.8. I have another issue since I pass through https the backend mode is tcp so I can’t change the http headers. Soon I will see the state of things and then dive deeper into the issue.
That’s just another confirmation that the problem is not haproxy. Haproxy cannot break encryption and change http headers, that is impossible without decrypting and reencrypting SSL.