use of org.eclipse.jetty.server.ProxyConnectionFactory in project jetty.project by eclipse.
the class UnixSocketServer method main.
public static void main(String... args) throws Exception {
Server server = new Server();
HttpConnectionFactory http = new HttpConnectionFactory();
ProxyConnectionFactory proxy = new ProxyConnectionFactory(http.getProtocol());
UnixSocketConnector connector = new UnixSocketConnector(server, proxy, http);
server.addConnector(connector);
server.setHandler(new AbstractHandler.ErrorDispatchHandler() {
@Override
protected void doNonErrorHandle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
baseRequest.setHandled(true);
response.setStatus(200);
response.getWriter().write("Hello World\r\n");
response.getWriter().write("remote=" + request.getRemoteAddr() + ":" + request.getRemotePort() + "\r\n");
response.getWriter().write("local =" + request.getLocalAddr() + ":" + request.getLocalPort() + "\r\n");
}
});
server.start();
server.join();
}
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) {
// SSL Context Factory
SslContextFactory 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 = null;
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);
server.addConnector(sslConnector);
}
use of org.eclipse.jetty.server.ProxyConnectionFactory in project dropwizard by dropwizard.
the class HttpConnectorFactory method buildConnector.
protected ServerConnector buildConnector(Server server, Scheduler scheduler, ByteBufferPool bufferPool, String name, @Nullable ThreadPool threadPool, ConnectionFactory... factories) {
if (useProxyProtocol) {
factories = ArrayUtil.prependToArray(new ProxyConnectionFactory(), factories, ConnectorFactory.class);
}
final ServerConnector connector = new ServerConnector(server, threadPool, scheduler, bufferPool, acceptorThreads.orElse(-1), selectorThreads.orElse(-1), factories);
connector.setPort(port);
connector.setHost(bindHost);
connector.setInheritChannel(inheritChannel);
if (acceptQueueSize != null) {
connector.setAcceptQueueSize(acceptQueueSize);
} else {
// if we do not set the acceptQueueSize, when jetty
// creates the ServerSocket, it uses the default backlog of 50, and
// not the value from the OS. Therefore we set to the value
// obtained from NetUtil, which will attempt to read the value from the OS.
// somaxconn setting
connector.setAcceptQueueSize(NetUtil.getTcpBacklog());
}
connector.setReuseAddress(reuseAddress);
connector.setIdleTimeout(idleTimeout.toMilliseconds());
connector.setName(name);
return connector;
}
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();
}
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);
}
Aggregations