我们有一个java服务器,可以通过h2c (HTTP/2明文)提供内容服务。
我们希望将使用h2 (即标准HTTP/2通过SSL)建立的代理连接反向到h2c中的java服务器。
在nginx上启用HTTP/2非常简单,并且处理传入的h2连接很好。
我们如何告诉nginx使用h2c而不是http/1.1代理连接?
注:非nginx溶液可接受。
server {
listen 443 ssl http2 default_server;
server_name localhost;
ssl_certificate /opt/nginx/certificates/???.pem;
ssl_certificate_key /opt/nginx/certificates/???.pk8.key.pem;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
location / {
proxy_pass http://localhost:8080/; ## <---- h2c here rather than http/1.1
}
}结论(2016年6月)
这可以通过使用像下面这样简单的配置文件使用haproxy来完成。
查询(HttpServletRequest) req.getProtocol()显然返回HTTP/2.0
global
tune.ssl.default-dh-param 1024
defaults
timeout connect 10000ms
timeout client 60000ms
timeout server 60000ms
frontend fe_http
mode http
bind *:80
# Redirect to https
redirect scheme https code 301
frontend fe_https
mode tcp
bind *:443 ssl no-sslv3 crt mydomain.pem ciphers TLSv1.2 alpn h2,http/1.1
default_backend be_http
backend be_http
mode tcp
server domain 127.0.0.1:8080发布于 2016-06-15 13:00:32
https://stackoverflow.com/questions/37835445
复制相似问题