HAProxy 1.8 does not redirect all http to https

Hello!

I have configured HAProxy with SSL (SSL termination solution). For the domain, it works well (exemple: http://example.com to https://example.com). But if the page contains http url, they are not redirected to https. Is this normal? Did I miss something in my config?

To redirect http to https, I have added in my section “frontend_http”:

redirect scheme https if !{ ssl_fc }

Thx!

Redirect means that haproxy emits a HTTP redirect with a 30x response, so that your browser goes to a different destination instead.

However redirect does not mean your HTTP payload (HTML) get’s modified. Haproxy will not read or modify your HTTP payload (if that’s what you mean by “if the page contains http url, they are not redirected to https”).

Thx for response.

No way to force the redirection for image or css or js included in html? on the backend maybe?

You are not asking for a redirection, you are asking to rewrite your HTML body.
You cannot do that with haproxy as-is. You may be able to do so with LUA, but you have to actually write code.

Instead of trying to rewrite the HTML body, usually you would work on the application side so that it understands that the request already comes in via a secure connection. For example with a X-Forwarded-Proto header.