简体   繁体   中英

how to redirect a url like https://example.com to https://www.example.com in haproxy

I know how to redirect from:

http example.com to https www.example.com and http www.example.com to https www.example.com

but don't know how to redirect from:

https example.com to https www.example.com in Haproxy

redirect prefix https://www.example.com code 301 if { hdr(host) -i example.com } in both frontend

frontend weblb
bind *:80
acl is_www hdr_beg(host) ilanni.com
redirect prefix https://www.ilanni.com code 301 if is_www

acl is_host hdr_beg(host) wwww.ilanni.com
redirect scheme https if !{ ssl_fc }
bind *:443 ssl crt /etc/haproxy/ilanni.com.pem

use_backend sellerserver if is_host

backend sellerserver
balance source
server web1 127.0.0.1:8111 maxconn 1024 weight 3 check inter 2000 rise 2 fall 3 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM