Skip to content

Commit e0d3305

Browse files
Make http2 communication configurable
1 parent 829a792 commit e0d3305

File tree

8 files changed

+24
-4
lines changed

8 files changed

+24
-4
lines changed

presto-docs/src/main/sphinx/security/ldap.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ Property Description
8585
Should be set to ``true``. Default value is
8686
``false``.
8787
``http-server.https.port`` HTTPS server port.
88+
``http-server.http2.enabled`` Enables HTTP2 server on the worker.
8889
``http-server.https.keystore.path`` The location of the Java Keystore file that will be
8990
used to secure TLS.
9091
``http-server.https.keystore.key`` The password for the keystore. This must match the

presto-docs/src/main/sphinx/security/server.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ Property Description
115115
``http-server.https.enabled`` Enables HTTPS access for the Presto coordinator.
116116
Should be set to ``true``.
117117
``http-server.https.port`` HTTPS server port.
118+
``http-server.http2.enabled`` Enables HTTP2 server on the worker.
118119
``http-server.https.keystore.path`` The location of the Java Keystore file that will be
119120
used to secure TLS.
120121
``http-server.https.keystore.key`` The password for the keystore. This must match the

presto-native-execution/presto_cpp/main/PrestoServer.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,8 +318,9 @@ void PrestoServer::run() {
318318
httpsSocketAddress.setFromLocalPort(httpsPort.value());
319319
}
320320

321+
const bool http2Enabled = SystemConfig::instance()->httpServerHttp2Enabled();
321322
httpsConfig = std::make_unique<http::HttpsConfig>(
322-
httpsSocketAddress, certPath, keyPath, ciphers, reusePort);
323+
httpsSocketAddress, certPath, keyPath, ciphers, reusePort, http2Enabled);
323324
}
324325

325326
httpServer_ = std::make_unique<http::HttpServer>(

presto-native-execution/presto_cpp/main/common/Configs.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ SystemConfig::SystemConfig() {
157157
NUM_PROP(kHttpServerNumCpuThreadsHwMultiplier, 1.0),
158158
NONE_PROP(kHttpServerHttpsPort),
159159
BOOL_PROP(kHttpServerHttpsEnabled, false),
160+
BOOL_PROP(kHttpServerHttp2Enabled, true),
160161
STR_PROP(
161162
kHttpsSupportedCiphers,
162163
"ECDHE-ECDSA-AES256-GCM-SHA384,AES256-GCM-SHA384"),
@@ -297,6 +298,10 @@ bool SystemConfig::httpServerHttpsEnabled() const {
297298
return optionalProperty<bool>(kHttpServerHttpsEnabled).value();
298299
}
299300

301+
bool SystemConfig::httpServerHttp2Enabled() const {
302+
return optionalProperty<bool>(kHttpServerHttp2Enabled).value();
303+
}
304+
300305
std::string SystemConfig::httpsSupportedCiphers() const {
301306
return optionalProperty(kHttpsSupportedCiphers).value();
302307
}

presto-native-execution/presto_cpp/main/common/Configs.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,8 @@ class SystemConfig : public ConfigBase {
202202
"http-server.https.port"};
203203
static constexpr std::string_view kHttpServerHttpsEnabled{
204204
"http-server.https.enabled"};
205+
static constexpr std::string_view kHttpServerHttp2Enabled{
206+
"http-server.http2.enabled"};
205207
/// List of comma separated ciphers the client can use.
206208
///
207209
/// NOTE: the client needs to have at least one cipher shared with server
@@ -785,6 +787,8 @@ class SystemConfig : public ConfigBase {
785787

786788
int httpServerHttpsPort() const;
787789

790+
bool httpServerHttp2Enabled() const;
791+
788792
/// A list of ciphers (comma separated) that are supported by
789793
/// server and client. Note Java and folly::SSLContext use different names to
790794
/// refer to the same cipher. For e.g. TLS_RSA_WITH_AES_256_GCM_SHA384 in Java

presto-native-execution/presto_cpp/main/common/Utils.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ std::shared_ptr<folly::SSLContext> createSSLContext(
3737
sslContext->loadCertKeyPairFromFiles(
3838
clientCertAndKeyPath.c_str(), clientCertAndKeyPath.c_str());
3939
sslContext->setCiphersOrThrow(ciphers);
40+
sslContext->setAdvertisedNextProtocols({"http/1.1"});
4041
return sslContext;
4142
} catch (const std::exception& ex) {
4243
LOG(FATAL) << fmt::format(

presto-native-execution/presto_cpp/main/http/HttpServer.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,14 @@ HttpsConfig::HttpsConfig(
106106
const std::string& certPath,
107107
const std::string& keyPath,
108108
const std::string& supportedCiphers,
109-
bool reusePort)
109+
bool reusePort,
110+
bool http2Enabled)
110111
: address_(address),
111112
certPath_(certPath),
112113
keyPath_(keyPath),
113114
supportedCiphers_(supportedCiphers),
114-
reusePort_(reusePort) {
115+
reusePort_(reusePort),
116+
http2Enabled_(http2Enabled) {
115117
// Wangle separates ciphers by ":" where in the config it's separated with ","
116118
std::replace(supportedCiphers_.begin(), supportedCiphers_.end(), ',', ':');
117119
}
@@ -126,6 +128,9 @@ proxygen::HTTPServer::IPConfig HttpsConfig::ipConfig() const {
126128
folly::SSLContext::VerifyClientCertificate::DO_NOT_REQUEST;
127129
sslCfg.setCertificate(certPath_, keyPath_, "");
128130
sslCfg.sslCiphers = supportedCiphers_;
131+
if (http2Enabled_) {
132+
sslCfg.setNextProtocols({"h2", "http/1.1"});
133+
}
129134

130135
ipConfig.sslConfigs.push_back(sslCfg);
131136

presto-native-execution/presto_cpp/main/http/HttpServer.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,8 @@ class HttpsConfig {
259259
const std::string& certPath,
260260
const std::string& keyPath,
261261
const std::string& supportedCiphers,
262-
bool reusePort = false);
262+
bool reusePort = false,
263+
bool http2Enabled = true);
263264

264265
proxygen::HTTPServer::IPConfig ipConfig() const;
265266

@@ -269,6 +270,7 @@ class HttpsConfig {
269270
const std::string keyPath_;
270271
std::string supportedCiphers_;
271272
const bool reusePort_;
273+
const bool http2Enabled_;
272274
};
273275

274276
class HttpServer {

0 commit comments

Comments
 (0)