use of org.eclipse.jetty.server.ProxyConnectionFactory in project athenz by yahoo.
the class AthenzJettyContainer method addHTTPConnector.
void addHTTPConnector(HttpConfiguration httpConfig, int httpPort, boolean proxyProtocol, String listenHost, int idleTimeout) {
ServerConnector connector;
if (proxyProtocol) {
connector = new ServerConnector(server, new ProxyConnectionFactory(), new HttpConnectionFactory(httpConfig));
} else {
connector = new ServerConnector(server, new HttpConnectionFactory(httpConfig));
}
if (!StringUtil.isEmpty(listenHost)) {
connector.setHost(listenHost);
}
connector.setPort(httpPort);
connector.setIdleTimeout(idleTimeout);
server.addConnector(connector);
}
use of org.eclipse.jetty.server.ProxyConnectionFactory in project athenz by yahoo.
the class AthenzJettyContainer method addHTTPSConnector.
void addHTTPSConnector(HttpConfiguration httpConfig, int httpsPort, boolean proxyProtocol, String listenHost, int idleTimeout, boolean needClientAuth, JettyConnectionLogger connectionLogger) {
// SSL Context Factory
SslContextFactory.Server sslContextFactory = createSSLContextObject(needClientAuth);
// SSL HTTP Configuration
HttpConfiguration httpsConfig = new HttpConfiguration(httpConfig);
httpsConfig.setSecureScheme("https");
httpsConfig.setSecurePort(httpsPort);
httpsConfig.addCustomizer(new SecureRequestCustomizer());
// SSL Connector
ServerConnector sslConnector;
if (proxyProtocol) {
sslConnector = new ServerConnector(server, new ProxyConnectionFactory(), new SslConnectionFactory(sslContextFactory, HttpVersion.HTTP_1_1.asString()), new HttpConnectionFactory(httpsConfig));
} else {
sslConnector = new ServerConnector(server, new SslConnectionFactory(sslContextFactory, HttpVersion.HTTP_1_1.asString()), new HttpConnectionFactory(httpsConfig));
}
sslConnector.setPort(httpsPort);
sslConnector.setIdleTimeout(idleTimeout);
if (listenHost != null) {
sslConnector.setHost(listenHost);
}
if (connectionLogger != null) {
sslConnector.addBean(connectionLogger);
}
server.addConnector(sslConnector);
// Reload the key-store if the file is changed
final int reloadSslContextSeconds = Integer.parseInt(System.getProperty(AthenzConsts.ATHENZ_PROP_KEYSTORE_RELOAD_SEC, "0"));
if ((reloadSslContextSeconds > 0) && (sslContextFactory.getKeyStorePath() != null)) {
try {
KeyStoreScanner keystoreScanner = new KeyStoreScanner(sslContextFactory);
keystoreScanner.setScanInterval(reloadSslContextSeconds);
server.addBean(keystoreScanner);
} catch (IllegalArgumentException exception) {
LOG.error("Keystore cant be automatically reloaded when \"{}\" is changed: {}", sslContextFactory.getKeyStorePath(), exception.getMessage());
throw exception;
}
}
}
use of org.eclipse.jetty.server.ProxyConnectionFactory in project jetty.project by eclipse.
the class ProxyProtocolTest method startServer.
public void startServer(Handler handler) throws Exception {
server = new Server();
HttpConfiguration configuration = new HttpConfiguration();
connector = new ServerConnector(server, new ProxyConnectionFactory(), new HTTP2CServerConnectionFactory(configuration));
server.addConnector(connector);
server.setHandler(handler);
client = new HTTP2Client();
server.addBean(client, true);
server.start();
}
Aggregations