所以这里是圣人:
负载均衡器(haproxy)交付给3个Web服务器和一个数据库服务器,共5台服务器,并且在Web服务器之间共享Memcache会话。 我可以确认PHPSESSIONID正在Web服务器之间共享,但是当我尝试login时, $_POST不断被重置,并且login的cookie从不设置,导致不断的redirect到login页面。
我已经在haproxy中设置了appsessionid ,而且这个工作正常,但是由于大多数用户都会login,所以它在使用负载均衡器的时候失败了,所以很可能一台服务器会比其他服务器获得更多的stream量。 有没有人遇到这个和任何想法如何解决? 还是我被迫使用粘性会话?
做了更多的研究,并意识到我可以在$_SESSION保存$_POST ,但可能会有一些安全问题。 我的想法是在每个页面的closures操作中将其从会话中清除。 思考?
这里是/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
我知道这是一个古老的线程,但不知道是否有一些在networking服务器上的303redirect。 在这种情况下,客户端将重试GET,POST数据将会丢失。 改用307redirect。