haproxy の背後にある WordPress: $_POST がリセットされる

haproxy の背後にある WordPress: $_POST がリセットされる

それで、状況は次のようになります:

ロード バランサ (haproxy) は 3 台の Web サーバーと 1 台のデータベース サーバーに配信し、memcache セッションは Web サーバー間で共有され、合計 5 台のサーバーに配信されます。Web サーバー間PHPSESSIONIDで共有されていることは確認できますが、ログインしようとすると$_POSTリセットされ続け、ログイン クッキーが設定されないため、ログイン ページに常にリダイレクトされます。

haproxy を設定しましたappsessionidが、これは機能しますが、ほとんどのユーザーがログインするため、ロード バランサーを使用する目的が達成されないため、1 つのサーバーが他のサーバーよりも多くのトラフィックを受信する可能性が高くなります。この問題に遭遇した方はいますか。また、解決方法はありますか。それとも、スティッキー セッションを使用する必要があるのでしょうか。

編集1:

さらに調査したところ、$_POSTに保存できることがわかりました$_SESSIONが、セキュリティ上の懸念があるかもしれません。私の考えでは、各ページのシャットダウン アクションでセッションから消去することになります。ご意見は?

編集2:

こちらは/etc/haproxy/haproxy.cfg

global
    log /dev/log    local0
    log /dev/log    local1 notice
    chroot /var/lib/haproxy
    stats socket /run/haproxy/admin.sock mode 660 level admin
    stats timeout 30s
    daemon
    user haproxy
    group haproxy

    # Default ciphers to use on SSL-enabled listening sockets.
    # For more information, see ciphers(1SSL).
    tune.ssl.default-dh-param 2048
    ssl-default-bind-ciphers LONG LIST OF CIPHERS

defaults
    log     global
    balance leastconn
    mode http
    option httplog
    option dontlognull
    option redispatch
    option http-server-close
    option forwardfor
    option abortonclose
    maxconn 3000
    retries 3
    timeout queue 1m
    timeout connect 10s                                                                                                                                
    timeout client 5m
    timeout server 5m
    timeout http-request 5s
    timeout http-keep-alive 10s
    timeout check  10s

frontend www-http
    bind xxx.xxx.xxx.xxx:80
    reqadd X-Forwarded-Proto:\ http
    redirect scheme https if !{ ssl_fc }
    default_backend wordpress-backend

frontend www-https
    bind xxx.xxx.xxx.xxx:443 ssl no-sslv3 crt /etc/ssl/private/default.pem crt /etc/ssl/private/
    rspadd  Strict-Transport-Security:\ max-age=15768000
    reqadd X-Forwarded-Proto:\ https
    default_backend wordpress-backend

backend wordpress-backend
    option httpchk HEAD /haphealth
    server wordpress-1 xxx.xxx.xxx.xxx:8081 maxconn 10 check
    server wordpress-2 xxx.xxx.xxx.xxx:8081 maxconn 10 check
    server wordpress-3 xxx.xxx.xxx.xxx:8081 maxconn 10 check

答え1

これは古いスレッドだとは思いますが、Web サーバーに 303 リダイレクトがあったかどうか疑問に思います。その場合、クライアントは GET で再試行し、POST データは失われます。代わりに 307 リダイレクトを使用してください。

答え2

同じページで安全な (https) データと安全でない (http) データの両方を返すサイトでこれを使用します。

frontend WordPress
 mode http
 option httplog
 bind <ip_address>:80 transparent
 bind <ip_address>:443 transparent ssl crt <path_to_cert>
 http-request set-header X-Forwarded-Proto https #  <------ This is the line makes sure everything that's requested is HTTPS
 redirect scheme https code 307 if !{ ssl_fc }
 default_backend wp_backend

その後、サイトのWP設定を「http://some_site.com' に 'https://some_site.com'。

期待通りに動作しました。

関連情報