use of org.eclipse.jetty.server.ForwardedRequestCustomizer in project zeppelin by apache.
the class ZeppelinServer method initServerConnector.
private static void initServerConnector(Server server, int port, int sslPort) {
ServerConnector connector;
HttpConfiguration httpConfig = new HttpConfiguration();
httpConfig.addCustomizer(new ForwardedRequestCustomizer());
httpConfig.setSendServerVersion(conf.sendJettyName());
httpConfig.setRequestHeaderSize(conf.getJettyRequestHeaderSize());
if (conf.useSsl()) {
LOG.debug("Enabling SSL for Zeppelin Server on port {}", sslPort);
httpConfig.setSecureScheme(HttpScheme.HTTPS.asString());
httpConfig.setSecurePort(sslPort);
HttpConfiguration httpsConfig = new HttpConfiguration(httpConfig);
httpsConfig.addCustomizer(new SecureRequestCustomizer());
SslConnectionFactory sslConnectionFactory = new SslConnectionFactory(getSslContextFactory(conf), HttpVersion.HTTP_1_1.asString());
HttpConnectionFactory httpsConnectionFactory = new HttpConnectionFactory(httpsConfig);
connector = new ServerConnector(server, sslConnectionFactory, httpsConnectionFactory);
connector.setPort(sslPort);
connector.addBean(new JettySslHandshakeMetrics(Metrics.globalRegistry, Tags.empty()));
} else {
HttpConnectionFactory httpConnectionFactory = new HttpConnectionFactory(httpConfig);
connector = new ServerConnector(server, httpConnectionFactory);
connector.setPort(port);
}
// Set some timeout options to make debugging easier.
int timeout = 1000 * 30;
connector.setIdleTimeout(timeout);
connector.setHost(conf.getServerAddress());
connector.addBean(new JettyConnectionMetrics(Metrics.globalRegistry, Tags.empty()));
server.addConnector(connector);
}
use of org.eclipse.jetty.server.ForwardedRequestCustomizer in project Openfire by igniterealtime.
the class HttpBindManager method configureProxiedConnector.
private void configureProxiedConnector(HttpConfiguration httpConfig) {
// Refer to http://eclipse.org/jetty/documentation/current/configuring-connectors.html
if (isXFFEnabled()) {
ForwardedRequestCustomizer customizer = new ForwardedRequestCustomizer();
// default: "X-Forwarded-For"
String forwardedForHeader = HTTP_BIND_FORWARDED_FOR.getValue();
if (forwardedForHeader != null) {
customizer.setForwardedForHeader(forwardedForHeader);
}
// default: "X-Forwarded-Server"
String forwardedServerHeader = HTTP_BIND_FORWARDED_SERVER.getValue();
if (forwardedServerHeader != null) {
customizer.setForwardedServerHeader(forwardedServerHeader);
}
// default: "X-Forwarded-Host"
String forwardedHostHeader = HTTP_BIND_FORWARDED_HOST.getValue();
if (forwardedHostHeader != null) {
customizer.setForwardedHostHeader(forwardedHostHeader);
}
// default: none
String hostName = getXFFHostName();
if (hostName != null) {
customizer.setHostHeader(hostName);
}
httpConfig.addCustomizer(customizer);
}
httpConfig.setRequestHeaderSize(HTTP_BIND_REQUEST_HEADER_SIZE.getValue());
}
Aggregations