HAProxy redirecting http to https (ssl)

前端 未结 16 1446
你的背包
你的背包 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:03

    The best guaranteed way to redirect everything http to https is:

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

    This is a little fancier using ‘code 301′, but might as well let the client know it’s permanent. The ‘mode http’ part is not essential with default configuration, but can’t hurt. If you have mode tcp in defaults section (like I did), then it’s necessary.

提交回复
热议问题