Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redirect http to https haproxy use ssl passthrough

Tags:

tcp

ssl

haproxy

here is my configuration

frontend www-http

   bind *:80

option tcplog

  default_backend www-backend

mode tcp

frontend www-https

   bind *:443

   default_backend www-backend

option tcplog

mode tcp

backend www-backend

mode tcp

   server web1 192.168.1.191:443 check

   server web2 192.168.1.192:443 check backup

I want to when users types mysite.com >> https://mysites.com

I used redirect scheme https if !{ ssl_fc } on frontend as backend, but it cant reach my goal.

like image 734
Khoi Nguyen Huu Avatar asked Mar 16 '26 13:03

Khoi Nguyen Huu


1 Answers

It may be late, but the following works:

frontend LB
    bind :80 v4v6
    mode http
    redirect scheme https if !{ ssl_fc }

frontend LBS
    bind :443 v4v6
    option tcplog
    mode tcp
    default_backend LBB

backend LBB
    mode tcp
    balance roundrobin
    option ssl-hello-chk
    server srv1 server1.example.com:443 check
    server srv2 server2.example.com:443 check backup
like image 150
NickAppletech Avatar answered Mar 19 '26 14:03

NickAppletech