Hello,
I am a novice in Haproxy : in my current configuration, http is redirected to https but I would like to redirect non www to www.
Here is the currect config of haproxy.cfg:
frontend frontend_http
bind 0.0.0.0:80 name http
bind 0.0.0.0:443 name https ssl crt /etc/haproxy/certificates/ ciphers HIGH:!aNULL:!MD5:RC4 no-sslv3 alpn h2,http/1.1
mode http
option httplog
option forwardfor
http-request set-header X-Forwarded-Proto https if { ssl_fc }
http-request set-header X-Forwarded-Proto http if !{ ssl_fc }
http-request set-header X-Client “%ci:%cp”
capture request header Host len 256
unique-id-format %[uuid()]
unique-id-header X-Trace-ID
log-format %ci:%cp\ [%t]\ %ft\ %b/%s\ %Tq/%Tw/%Tc/%Tr/%Tt\ %ST\ %B\ %CC\ %CS\ %tsc\ %ac/%fc/%bc/%sc/%rc\ %sq/%bq\ %{+Q}r\ %{+Q}[capture.req.hdr(0)]\ %ID
# Force redirection HTTP -> HTTPS for all sites
#redirect scheme https code 301 if !{ ssl_fc }
redirect scheme https code 301 if !{ ssl_fc } !{ path_beg -i /.well-known/acme-challenge/ }
acl _dom_example_prd hdr(Host) -i prod.example.com www.example.com example.com
acl _path_certbot path_beg -i /.well-known/acme-challenge/
use_backend be_certbot if _path_certbot
use_backend be_example_prd if _dom_example_prd
Note : I have other sites which are not concerned.
What should I change for http://example.com or https://example.com to be redirected to https://www.example.com (and to keep http to https behaviour)?
Thanks in advance.