https://github.com/eclipse/jetty.project下的所有示例都有ssl工厂。
就我而言,使用自签名证书在nginx级别上完成了ssl卸载。
我需要的只是配置了h2连接器(甚至没有h1)。
使用h2c
通过HTTP2CServerConnectionFactory
连接器设置码头。
如果使用jetty-home
(或更旧的jetty-distribution
),只需启用http2c
模块。
如果使用嵌入式码头,则对连接器使用以下粗略轮廓。
HttpConfiguration config = new HttpConfiguration();
// ... configure
HTTP2CServerConnectionFactory http2c = new HTTP2CServerConnectionFactory(config);
ServerConnector connector = new ServerConnector(this, http1, http2c);
connector.setPort(port);
server.addConnector(connector);