Я пытаюсь иметь Прокси HA 301, перенаправляют https домен. Мне нужно:
https://example.com для перенаправления к https://www.example.com
Это - то, что я пытался заставить это работать:
# corp - example.com
redirect prefix https://www.example.com code 301 if { hdr(host) -i example.com }
redirect prefix https://www.example.com code 301 if { hdr(host) -i www.example.com }
acl server01 hdr_dom(host) -i www.example.com
Я был бы очень признателен за любую справку!
ОТРЕДАКТИРОВАННЫЙ ПРИМЕР cfg ФАЙЛА (Код в основе является частью cfg):
global log /dev/log local0 log /dev/log local1 notice chroot /var/lib/haproxy user haproxy group haproxy daemondefaults log global maxconn 100000 mode http option httplog option dontlognull option forwardfor timeout connect 600000ms timeout server 600000ms timeout client 600000ms errorfile 400 /etc/haproxy/errors/400.http errorfile 403 /etc/haproxy/errors/403.http errorfile 408 /etc/haproxy/errors/408.http errorfile 500 /etc/haproxy/errors/500.http errorfile 502 /etc/haproxy/errors/502.http errorfile 503 /etc/haproxy/errors/503.http errorfile 504 /etc/haproxy/errors/504.http
frontend main_http_proxy bind *:80 mode http http-request add-header X-Forwarded-Proto https if { ssl_fc } stats enable stats uri /haproxystatus?stats stats realm Strickly\ Private stats auth ec2ops:7is92kc81k92kds8
# example.com #redirect scheme https code 301 if { hdr(host) -i www.example.com } !{ ssl_fc } #redirect prefix https://www.example.com code 301 if { hdr(host) -i example.com } !{ ssl_fc } #redirect prefix https://www.example.com code 301 if { hdr(host) -i example.com } #redirect prefix https://www.example.com code 301 if { hdr(host) -i www.example.com } acl no_WWW hdr(host) -i example.com redirect prefix www.example.com code 301 if no_WWW # Backend Rules use_backend SERVER01 if jcma01 use_backend SERVER01 if no_WWW
frontend main_https_proxy bind :443 ssl crt /etc/haproxy/pem/ mode http http-request add-header X-Forwarded-Proto https if { ssl_fc } acl secure dst_port eq 443 rsprep ^Set-Cookie:\ (.) Set-Cookie:\ \1;\ Secure if secure rspadd Strict-Transport-Security:\ max-age=31536000 if secure
use_backend SERVER01 if { ssl_fc_sni www.example.com } #use_backend SERVER01 if { ssl_fc_sni example.com }
бэкенд server01 источник cookie SERVER01 баланса вставляет проверку сервера SERVER01 10.10.10.10:80 cookie SERVER01, предают 5 с земле
Не знаете, где у вас эти ACL, разве не будет
redirect scheme https code 301 if !{ ssl_fc }
или
redirect scheme https code 301 if {hdr(host) -i yourdomain.example.com } !{ ssl_fc }
более чистым решением?