Bru*_*der 6 java reverse-proxy nginx haproxy http2
我们有一个java web服务器,可以通过h2c(HTTP/2明文)提供内容
我们希望将使用h2(即SSL上的标准HTTP/2)建立的代理连接反向到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
}
}
Run Code Online (Sandbox Code Playgroud)
结论 (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
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1510 次 |
| 最近记录: |