请注意,这也已发布在http://thread.gmane.org/gmane.comp.web.haproxy/27737
我们正在尝试configuration这个架构:
ELB按照http://amzn.to/1YajEG3中的说明发送代理标头
HAproxy在443中侦听SSL
一旦ELBconfiguration为SSL +代理协议,我们尝试通过在HTTPS前端的绑定中添加accept-proxy来configurationHAProxy:
frontend https-in mode http # Note, I truncated this line because the maillist 80 chars limitations bind :443 accept-proxy ssl crt \ /var/vcap/jobs/haproxy/config/cert.pem \ no-sslv3 ciphers ... ...
但它失败了: Received something which does not look like a PROXY protocol header 。
疑难解答我发现ELB发送SSLstream的PROXY头INSIDE。 例如,我运行openssl作为服务器:
$ openssl s_server -accept 443 -cert cert.pem ... ACCEPT bad gethostbyaddr -----BEGIN SSL SESSION PARAMETERS----- MFUCAQECAgMDBAIAnwQABDBsAWD78V/tz9KhYw4R/kpL5YPBxfF1qcmzxlclNDuz 0KWw9aGojVogjtBkH/zZOLWhBgIEVyoquqIEAgIBLKQGBAQBAAAA -----END SSL SESSION PARAMETERS----- Shared ciphers:... CIPHER is DHE-RSA-AES256-GCM-SHA384 Secure Renegotiation IS supported PROXY TCP4 80.194.77.90 192.168.6.14 39220 443 GET / HTTP/1.1 User-Agent: curl/7.35.0 Host: something.com Accept: */*
所以我在haproxy中做了一个“chained”configuration,一个用纯TCP完成SSLterminal,另一个用来“提取”代理协议并执行HTTP转换:
listen https-in mode tcp bind :443 ssl crt /var/vcap/jobs/haproxy/config/cert.pem no-sslv3 ciphers ... server http 127.0.0.1:8081 frontend http-in-from-ssl mode http bind :8081 accept-proxy option httplog option forwardfor reqadd X-Forwarded-Proto:\ https default_backend http-routers
那可行!
所以我的问题是:
谢谢!
我也遇到了这个问题。 但是,我在内部负载均衡器上使用nginx而不是HA代理。
解决scheme是类似的,但我认为这是值得发布:
#nginx.conf user nginx; worker_processes 1; error_log /dev/stderr debug; pid /var/run/nginx.pid; events { worker_connections 1024; } stream { upstream stream_backend { server 127.0.0.1:500; } server{ listen 443 ssl; proxy_pass stream_backend; ssl_certificate /certs/local/public.crt; ssl_certificate_key /certs/local/private.key; ssl_protocols TLSv1.2; ssl_ciphers HIGH:!aNULL:!MD5; } } http { include /etc/nginx/mime.types; default_type application/octet-stream; log_format main '[$host] $remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /dev/stdout main; sendfile on; #tcp_nopush on; keepalive_timeout 60; #gzip on; server { listen 8000; location /elb-status { keepalive_timeout 0; # Disable HTTP keepalive access_log off; return 200; } } map $http_upgrade $connection_upgrade { default upgrade; '' close; } server { listen 80 proxy_protocol; server_name test-nginx.corp.com; location / { keepalive_timeout 0; # Disable HTTP keepalive return 301 https://$host$request_uri; } } upstream nginx-test-stack { server 10.42.111.6:80; } server { listen 127.0.0.1:500 proxy_protocol; server_name test-nginx.corp.com; real_ip_header proxy_protocol; location / { proxy_pass http://nginx-test-stack; } } }
这使我可以为任何TCP连接启用E2Eencryption。 如果需要,我可以代理websockets或https或只是直接的TCP