HAProxy redirecting http to https (ssl)

前端 未结 16 1439
你的背包
你的背包 2020-12-22 22:04

I\'m using HAProxy for load balancing and only want my site to support https. Thus, I\'d like to redirect all requests on port 80 to port 443.

How would I do this?<

相关标签:
16条回答
  • 2020-12-22 23:05

    redirect statement is legacy

    use http-request redirect instead

    acl http      ssl_fc,not
    http-request redirect scheme https if http
    
    0 讨论(0)
  • 2020-12-22 23:05
      acl host-example hdr(host) -i www.example.com
    
      # for everything not https
      http-request redirect scheme https code 301 unless { ssl_fc }
    
      # for anything matching acl
      http-request redirect scheme https code 301 if host-example !{ ssl_fc }
    
    0 讨论(0)
  • 2020-12-22 23:06

    Simply:

    frontend incoming_requsts
            bind *:80
            bind *:443 ssl crt *path_to_cert*.**pem**
            **http-request redirect scheme https unless { ssl_fc }**
            default_backend k8s_nodes
    
    0 讨论(0)
  • 2020-12-22 23:07

    Can be done like this -

      frontend http-in
       bind *:80
       mode http
       redirect scheme https code 301
    

    Any traffic hitting http will redirect to https

    0 讨论(0)
提交回复
热议问题