我们试图让HAProxy侦听来自端口443(HTTPS&WSS)的所有传入stream量,
以下是我们的HAProxyconfiguration:
frontend wwws bind 0.0.0.0:443 ssl crt /etc/haproxy/server.pem timeout client 1h default_backend www_backend backend www_backend mode http stats enable stats uri /haproxy option forwardfor reqadd x-forwarded-proto:\ https server server1 backend:3000 weight 1 maxconn 8192 check
0.0.0.0:443(例如https://example.com )是我们的HA代理服务器监听所有传入的后端stream量:3000是我们的nginx服务器,它被设置为监听SSL连接
目前我们面临的问题是当我们inputhttps://example.com时 ,浏览器显示以下错误:
400 Bad Request The plain HTTP request was sent to HTTPS port nginx/1.7.5
这似乎是当haproxy转发stream量到nginx(后端:3000)它转换为http。
我认为“reqadd x -forwarded-proto:\ https”是假设确保它是https。
不知道我们的haproxyconfiguration有什么问题。
将后端服务器规范更改为:
server server1 backend:3000 weight 1 maxconn 8192 check ssl verify none
“ssl”部分定义后端说SSL,如果不存在,haproxy将默认为普通HTTP。 “verify none”会禁用证书检查,无论如何您可能不想对内部服务器执行此操作。