私は、httpとhttpsの2つのフロントエンドと、domain2backendマップを使用して選択される多くのバックエンドを持つハプロキシクラスタを持っています。バックエンドでのHAProxyリダイレクト方式が動作しない
一部のバックエンドは、HTTPSを介してのみアクセスする必要があります。
これらのバックエンドでredirect scheme https code 301 if !{ ssl_fc }
を使用しようとしましたが、ハプロキシはそれを無視しているようです。私は単にリダイレクトしようとしましたが(条件なし)、バックエンドセクションのリダイレクトは無視されます。
設定の抜粋:
global
maxconn 1024
debug
log localhost local0 debug
tune.ssl.default-dh-param 2048
defaults
balance roundrobin
maxconn 32
log global
monitor-uri /haproxy_test
timeout connect 5000ms
timeout client 50000ms
timeout server 50000ms
frontend http-in
bind *:8080
mode http
option httplog
option forwardfor
use_backend %[req.hdr(host),lower,map_dom(./etc/domain2backend.map)]
frontend https-in
bind *:4443 ssl crt ./etc/ssl
mode http
option httplog
option forwardfor
http-request add-header X-Proto https if { ssl_fc }
use_backend %[req.hdr(host),lower,map_dom(./etc/domain2backend.map)]
backend app1_www
redirect scheme https if !{ ssl_fc }
server localhost:3000 127.0.0.1:3000 check
backend app2_www
redirect scheme https
server localhost:3000 127.0.0.1:3000 check
app1_wwwもapp2_wwwどちらも仕事をリダイレクトします。
でmode http
を指定する必要がある:私はhttp://discourse.haproxy.orgに役立つコミュニティに多くの試みと感謝した後HA-Proxyバージョン1.7.3 2017年2月28日