Search in sources :

Example 16 with HTTP2ServerConnectionFactory

use of org.eclipse.jetty.http2.server.HTTP2ServerConnectionFactory in project jetty.project by eclipse.

the class DrupalHTTP2FastCGIProxyServer method main.

public static void main(String[] args) throws Exception {
    SslContextFactory sslContextFactory = new SslContextFactory();
    sslContextFactory.setEndpointIdentificationAlgorithm("");
    sslContextFactory.setKeyStorePath("src/test/resources/keystore.jks");
    sslContextFactory.setKeyStorePassword("storepwd");
    sslContextFactory.setTrustStorePath("src/test/resources/truststore.jks");
    sslContextFactory.setTrustStorePassword("storepwd");
    sslContextFactory.setCipherComparator(new HTTP2Cipher.CipherComparator());
    Server server = new Server();
    // HTTP(S) Configuration
    HttpConfiguration config = new HttpConfiguration();
    HttpConfiguration https_config = new HttpConfiguration(config);
    https_config.addCustomizer(new SecureRequestCustomizer());
    // HTTP2 factory
    HTTP2ServerConnectionFactory h2 = new HTTP2ServerConnectionFactory(https_config);
    ALPNServerConnectionFactory alpn = new ALPNServerConnectionFactory();
    alpn.setDefaultProtocol(h2.getProtocol());
    // SSL Factory
    SslConnectionFactory ssl = new SslConnectionFactory(sslContextFactory, alpn.getProtocol());
    // HTTP2 Connector
    ServerConnector http2Connector = new ServerConnector(server, ssl, alpn, h2, new HttpConnectionFactory(https_config));
    http2Connector.setPort(8443);
    http2Connector.setIdleTimeout(15000);
    server.addConnector(http2Connector);
    // Drupal seems to only work on the root context,
    // at least out of the box without additional plugins
    String root = "/home/simon/programs/drupal-7.23";
    ServletContextHandler context = new ServletContextHandler(server, "/");
    context.setResourceBase(root);
    context.setWelcomeFiles(new String[] { "index.php" });
    // Serve static resources
    ServletHolder defaultServlet = new ServletHolder(DefaultServlet.class);
    defaultServlet.setName("default");
    context.addServlet(defaultServlet, "/");
    // FastCGI
    ServletHolder fcgiServlet = new ServletHolder(FastCGIProxyServlet.class);
    fcgiServlet.setInitParameter(FastCGIProxyServlet.SCRIPT_ROOT_INIT_PARAM, root);
    fcgiServlet.setInitParameter("proxyTo", "http://localhost:9000");
    fcgiServlet.setInitParameter("prefix", "/");
    fcgiServlet.setInitParameter(FastCGIProxyServlet.SCRIPT_PATTERN_INIT_PARAM, "(.+\\.php)");
    context.addServlet(fcgiServlet, "*.php");
    server.start();
}
Also used : SecureRequestCustomizer(org.eclipse.jetty.server.SecureRequestCustomizer) Server(org.eclipse.jetty.server.Server) HttpConnectionFactory(org.eclipse.jetty.server.HttpConnectionFactory) ALPNServerConnectionFactory(org.eclipse.jetty.alpn.server.ALPNServerConnectionFactory) ServletHolder(org.eclipse.jetty.servlet.ServletHolder) HttpConfiguration(org.eclipse.jetty.server.HttpConfiguration) HTTP2ServerConnectionFactory(org.eclipse.jetty.http2.server.HTTP2ServerConnectionFactory) SslConnectionFactory(org.eclipse.jetty.server.SslConnectionFactory) ServerConnector(org.eclipse.jetty.server.ServerConnector) SslContextFactory(org.eclipse.jetty.util.ssl.SslContextFactory) HTTP2Cipher(org.eclipse.jetty.http2.HTTP2Cipher) ServletContextHandler(org.eclipse.jetty.servlet.ServletContextHandler)

Example 17 with HTTP2ServerConnectionFactory

use of org.eclipse.jetty.http2.server.HTTP2ServerConnectionFactory in project jetty.project by eclipse.

the class AbstractTest method start.

protected void start(HttpServlet servlet) throws Exception {
    prepareServer(new HTTP2ServerConnectionFactory(new HttpConfiguration()));
    ServletContextHandler context = new ServletContextHandler(server, "/", true, false);
    context.addServlet(new ServletHolder(servlet), servletPath + "/*");
    customizeContext(context);
    server.start();
    prepareClient();
    client.start();
}
Also used : ServletHolder(org.eclipse.jetty.servlet.ServletHolder) RawHTTP2ServerConnectionFactory(org.eclipse.jetty.http2.server.RawHTTP2ServerConnectionFactory) HTTP2ServerConnectionFactory(org.eclipse.jetty.http2.server.HTTP2ServerConnectionFactory) HttpConfiguration(org.eclipse.jetty.server.HttpConfiguration) ServletContextHandler(org.eclipse.jetty.servlet.ServletContextHandler)

Example 18 with HTTP2ServerConnectionFactory

use of org.eclipse.jetty.http2.server.HTTP2ServerConnectionFactory in project shareNice by mischat.

the class FileServer method main.

public static void main(String[] args) throws Exception {
    QueuedThreadPool threadPool = new QueuedThreadPool(100);
    // The Jetty Server.
    Server server = new Server(threadPool);
    // Custome FileHandler
    FileHandler handler = new FileHandler("src/main/website");
    server.setHandler(handler);
    // HTTP Configuration
    HttpConfiguration http_config = new HttpConfiguration();
    http_config.setSecureScheme("https");
    http_config.setSecurePort(HTTPS_PORT);
    http_config.setSendXPoweredBy(true);
    http_config.setSendServerVersion(true);
    // HTTPS Configuration
    HttpConfiguration https_config = new HttpConfiguration(http_config);
    https_config.addCustomizer(new SecureRequestCustomizer(true));
    // HTTP Connector
    ServerConnector http = new ServerConnector(server, new HttpConnectionFactory(http_config));
    http.setPort(HTTP_PORT);
    server.addConnector(http);
    // SSL Context Factory for HTTPS and HTTP/2
    SslContextFactory sslContextFactory = new SslContextFactory();
    sslContextFactory.setKeyStorePath("/tmp/keystore/keystore.jks");
    sslContextFactory.setKeyStorePassword("storepwd");
    sslContextFactory.setTrustStorePath("/tmp/keystore/truststore.jks");
    sslContextFactory.setTrustStorePassword("storepwd");
    sslContextFactory.setCipherComparator(HTTP2Cipher.COMPARATOR);
    sslContextFactory.setUseCipherSuitesOrder(true);
    sslContextFactory.setExcludeCipherSuites("SSL_RSA_WITH_DES_CBC_SHA", "SSL_DHE_RSA_WITH_DES_CBC_SHA", "SSL_DHE_DSS_WITH_DES_CBC_SHA", "SSL_RSA_EXPORT_WITH_RC4_40_MD5", "SSL_RSA_EXPORT_WITH_DES40_CBC_SHA", "SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA", "SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA");
    // HTTP/2 Connection Factory
    HTTP2ServerConnectionFactory h2 = new HTTP2ServerConnectionFactory(https_config);
    NegotiatingServerConnectionFactory.checkProtocolNegotiationAvailable();
    ALPNServerConnectionFactory alpn = new ALPNServerConnectionFactory("h2", "h2-17", "h2-16", "h2-15", "h2-14", "http/1.1");
    alpn.setDefaultProtocol(http.getDefaultProtocol());
    // SSL Connection Factory
    SslConnectionFactory ssl = new SslConnectionFactory(sslContextFactory, alpn.getProtocol());
    // HTTP/2 Connector
    ServerConnector http2Connector = new ServerConnector(server, ssl, alpn, h2, new HttpConnectionFactory(https_config));
    http2Connector.setPort(HTTPS_PORT);
    server.addConnector(http2Connector);
    ALPN.debug = true;
    server.start();
    server.setDumpAfterStart(true);
    server.dumpStdErr();
    server.join();
}
Also used : SslContextFactory(org.eclipse.jetty.util.ssl.SslContextFactory) QueuedThreadPool(org.eclipse.jetty.util.thread.QueuedThreadPool) ALPNServerConnectionFactory(org.eclipse.jetty.alpn.server.ALPNServerConnectionFactory) HTTP2ServerConnectionFactory(org.eclipse.jetty.http2.server.HTTP2ServerConnectionFactory)

Example 19 with HTTP2ServerConnectionFactory

use of org.eclipse.jetty.http2.server.HTTP2ServerConnectionFactory in project cayenne by apache.

the class Http2Server method main.

public static void main(String... args) throws Exception {
    // Setting Protostuff properties
    System.setProperty("protostuff.runtime.collection_schema_on_repeated_fields", "true");
    System.setProperty("protostuff.runtime.morph_collection_interfaces", "true");
    System.setProperty("protostuff.runtime.morph_map_interfaces", "true");
    System.setProperty("protostuff.runtime.pojo_schema_on_collection_fields", "true");
    System.setProperty("protostuff.runtime.pojo_schema_on_map_fields", "true");
    Server server = new Server();
    ServletContextHandler context = new ServletContextHandler(server, "/", ServletContextHandler.SESSIONS);
    context.addServlet(new ServletHolder("cayenne-project", new Http2ROPServlet()), "/");
    context.setSecurityHandler(basicAuth("cayenne-user", "secret", "Cayenne Realm"));
    server.setHandler(context);
    // HTTPS Configuration
    HttpConfiguration httpsConfig = new HttpConfiguration();
    httpsConfig.setSecureScheme("https");
    httpsConfig.setSecurePort(8443);
    httpsConfig.addCustomizer(new SecureRequestCustomizer());
    // SSL Context Factory for HTTPS and HTTP/2
    SslContextFactory sslContextFactory = new SslContextFactory();
    sslContextFactory.setKeyStoreResource(newClassPathResource("keystore"));
    sslContextFactory.setKeyStorePassword("OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4");
    sslContextFactory.setKeyManagerPassword("OBF:1u2u1wml1z7s1z7a1wnl1u2g");
    sslContextFactory.setCipherComparator(HTTP2Cipher.COMPARATOR);
    // SSL Connection Factory
    SslConnectionFactory ssl = new SslConnectionFactory(sslContextFactory, "h2");
    // HTTP/2 Connector
    ServerConnector http2Connector = new ServerConnector(server, ssl, new HTTP2ServerConnectionFactory(httpsConfig));
    http2Connector.setPort(8443);
    server.addConnector(http2Connector);
    server.start();
    server.join();
}
Also used : ServerConnector(org.eclipse.jetty.server.ServerConnector) SslContextFactory(org.eclipse.jetty.util.ssl.SslContextFactory) SecureRequestCustomizer(org.eclipse.jetty.server.SecureRequestCustomizer) Server(org.eclipse.jetty.server.Server) ServletHolder(org.eclipse.jetty.servlet.ServletHolder) HttpConfiguration(org.eclipse.jetty.server.HttpConfiguration) HTTP2ServerConnectionFactory(org.eclipse.jetty.http2.server.HTTP2ServerConnectionFactory) ServletContextHandler(org.eclipse.jetty.servlet.ServletContextHandler) SslConnectionFactory(org.eclipse.jetty.server.SslConnectionFactory)

Aggregations

HttpConfiguration (org.eclipse.jetty.server.HttpConfiguration)18 HTTP2ServerConnectionFactory (org.eclipse.jetty.http2.server.HTTP2ServerConnectionFactory)17 ServerConnector (org.eclipse.jetty.server.ServerConnector)12 Server (org.eclipse.jetty.server.Server)11 HttpConnectionFactory (org.eclipse.jetty.server.HttpConnectionFactory)10 ALPNServerConnectionFactory (org.eclipse.jetty.alpn.server.ALPNServerConnectionFactory)9 SslConnectionFactory (org.eclipse.jetty.server.SslConnectionFactory)9 SslContextFactory (org.eclipse.jetty.util.ssl.SslContextFactory)9 SecureRequestCustomizer (org.eclipse.jetty.server.SecureRequestCustomizer)8 ServletContextHandler (org.eclipse.jetty.servlet.ServletContextHandler)8 ServletHolder (org.eclipse.jetty.servlet.ServletHolder)8 HTTP2Cipher (org.eclipse.jetty.http2.HTTP2Cipher)3 HTTP2CServerConnectionFactory (org.eclipse.jetty.http2.server.HTTP2CServerConnectionFactory)3 QueuedThreadPool (org.eclipse.jetty.util.thread.QueuedThreadPool)3 Jetty93InstrumentedConnectionFactory (io.dropwizard.jetty.Jetty93InstrumentedConnectionFactory)2 IOException (java.io.IOException)2 ServletException (javax.servlet.ServletException)2 HttpServlet (javax.servlet.http.HttpServlet)2 HttpServletRequest (javax.servlet.http.HttpServletRequest)2 HttpServletResponse (javax.servlet.http.HttpServletResponse)2