
그래서 여기 상황이 있습니다:
3개의 웹 서버와 데이터베이스 서버, 총 5개의 서버에 전달되는 로드 밸런서(haproxy)는 웹 서버 간에 공유되는 Memcache 세션을 포함합니다. PHPSESSIONID
웹 서버 간에 공유되고 있음 을 확인할 수 있지만 로그인을 시도하면 $_POST
계속 재설정되고 로그인된 쿠키가 설정되지 않아 로그인 페이지로 계속 리디렉션됩니다.
haproxy를 설정했는데 appsessionid
작동하지만 대부분의 사용자가 로그인하므로 로드 밸런서를 사용하는 목적이 무산되므로 한 서버가 다른 서버보다 더 많은 트래픽을 받을 가능성이 높습니다. 누구든지 이 문제를 겪고 해결 방법을 알고 있습니까? 아니면 고정 세션을 사용해야 합니까?
편집 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
나는 이것이 오래된 스레드라는 것을 알고 있지만 웹 서버에 약 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'.
이것은 예상대로 작동했습니다.