在使用stunnel的HAproxy 1.4上使用HTTPS

我正在HAproxy上运行负载均衡服务器,并在同一台机器上使用stunnel实现Https,在实际的网页上,我有两个不同的networking,A和B,具有类似的行为。

以下是Stunnel的configuration:

sslVersion = SSLv3 chroot = /var/run/stunnel/ setuid = nobody setgid = nobody sslVersion = SSLv3 chroot = /var/run/stunnel/ setuid = nobody setgid = nobody pid = /stunnel.pid debug = 7 output = /var/log/stunnel.log [web_A] accept = 192.168.5.241:443 connect = 192.168.5.241:80 verify = 1 cert = /etc/stunnel/webA-cert-key.pem CAfile = /etc/stunnel/cert.ca.pem key = /etc/ssl/certs/webA-private.key [web_B] accept = 192.168.5.242:443 connect = 192.168.5.242:80 cert = /etc/stunnel/webB/webB.cert.pem key = /etc/ssl/certs/webB/webB.key.pem CAfile = /etc/stunnel/ca.cert.pem 

和HAproxy:

 global log 127.0.0.1 local0 log 127.0.0.1 local1 notice maxconn 100000 user haproxy group haproxy daemon defaults log global mode http option http-server-close option httplog retries 3 option redispatch maxconn 100000 contimeout 5000 clitimeout 50000 srvtimeout 50000 listen webA-farm 192.168.5.241:80 stats enable stats auth admin:admin stats uri /stats/ balance roundrobin option forwardfor cookie JSESSIONID prefix server web1 192.168.1.231:80 cookie JSESSIONID_S1 weight 100 check listen webB-farm 192.168.5.242:80 stats enable stats auth admin:admin stats uri /stats/ balance roundrobin option forwardfor cookie CL insert indirect nocache server web2 192.168.1.233:80 weight 100 check cookie CL2 

它适用于networkingA,但不适用于networkingB,这是我的问题。 我试图在两个networking上使用相同types的cookie,但没有奏效。 还redid的密钥和证书(我是我自己的CA),但问题仍然存在。

还有什么我可以检查,以解决这个问题?

谢谢。

编辑1:

这里是两个Web的httpd代理configuration:

networkingA在这里我redirect连接从端口80到端口8020的networkingA的tomcat,并确保它请求HTTPS而不是http:

 NameVirtualHost *:80 <VirtualHost 192.168.1.231:80> ServerAdmin [email protected] DocumentRoot /var/www/ ServerName webA.com ServerAlias webA.com ProxyRequests Off ProxyPreserveHost On RewriteEngine On <Proxy *> Order deny,allow Allow from all </Proxy> RewriteCond %{HTTPS} off RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] RewriteCond %{REQUEST_URI} ^/$ RewriteRule ^/(.*)$ /Track [R,L] #RewriteRule ^(.*)$ http://127.0.0.1:8020/trackA/Track [P,L] RewriteCond %{REQUEST_URI} ^/Track$ RewriteRule ^/(.*)$ http://127.0.0.1:8020/trackA/$1 [P,L] RewriteCond %{REQUEST_URI} ^/Track(.*) RewriteRule ^/(Track)/(.*)$ http://127.0.0.1:8020/track3/$2 [P,L] RewriteCond %{REQUEST_URI} ^.*$ RewriteRule ^/(.*)$ http://127.0.0.1:8020/trackA/$1 [P,L] ProxyPassReverse / /track3/ #ProxyPassReverse / https://127.0.0.1:8020/trackA/ ProxyPassReverseCookiePath / / #ProxyPassReverseCookiePath / http://192.168.5.241/track3/ RewriteLog "/var/log/httpd/rewrite.log" RewriteLogLevel 5 ErrorLog "logs/error.log" CustomLog "logs/access.log" common </VirtualHost> 

Web B相同:

 NameVirtualHost *:80 <VirtualHost 192.168.1.233:80> ServerAdmin [email protected] DocumentRoot /var/www/ ServerName webB.com ServerAlias webB.com ProxyRequests Off ProxyPreserveHost On RewriteEngine On <Proxy *> Order deny,allow Allow from all </Proxy> RewriteCond %{HTTPS} off RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] RewriteCond %{REQUEST_URI} ^/$ RewriteRule ^/(.*)$ /Track [R,L] RewriteCond %{REQUEST_URI} ^/Track$ RewriteRule ^/(.*)$ http://127.0.0.1:8020/trackB/$1 [P,L] RewriteCond %{REQUEST_URI} ^/repot/(.*)$ RewriteRule ^/(.*)$ http://192.168.1.121/$1 [P,L] RewriteCond %{REQUEST_URI} ^.*$ RewriteRule ^/(.*)$ http://127.0.0.1:8020/trackB/$1 [P,L] #ProxyPassReverse / http://192.168.5.242/ ProxyPassReverse / / ProxyPassReverseCookiePath / / RewriteLog "/var/log/httpd/rewrite.log" RewriteLogLevel 5 ErrorLog "logs/errror.log" CustomLog "logs/access.log" common </VirtualHost> 

编辑2:

当我去networkingB我得到这个消息:

该页面没有正确redirect

Firefox已经检测到服务器正以一种永远不会完成的方式redirect这个地址的请求。

 This problem can sometimes be caused by disabling or refusing to accept cookies. 

尝试设置haproxy 1.5并摆脱stunnel