当前位置: 首页>>代码示例>>Java>>正文


Java ForwardedRequestCustomizer类代码示例

本文整理汇总了Java中org.eclipse.jetty.server.ForwardedRequestCustomizer的典型用法代码示例。如果您正苦于以下问题:Java ForwardedRequestCustomizer类的具体用法?Java ForwardedRequestCustomizer怎么用?Java ForwardedRequestCustomizer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ForwardedRequestCustomizer类属于org.eclipse.jetty.server包,在下文中一共展示了ForwardedRequestCustomizer类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: buildHttpConfiguration

import org.eclipse.jetty.server.ForwardedRequestCustomizer; //导入依赖的package包/类
protected HttpConfiguration buildHttpConfiguration() {

        HttpConfiguration httpConfig = new HttpConfiguration();

        // most parameters are hardcoded for now... we should turn these
        // into properties

        httpConfig.setHeaderCacheSize(512);
        httpConfig.setOutputBufferSize(32 * 1024);
        httpConfig.setRequestHeaderSize(requestHeaderSize);
        httpConfig.setResponseHeaderSize(responseHeaderSize);
        httpConfig.setSendDateHeader(true);
        httpConfig.setSendServerVersion(true);

        httpConfig.addCustomizer(new ForwardedRequestCustomizer());

        return httpConfig;
    }
 
开发者ID:bootique,项目名称:bootique-jetty,代码行数:19,代码来源:ConnectorFactory.java

示例2: customize

import org.eclipse.jetty.server.ForwardedRequestCustomizer; //导入依赖的package包/类
@Override
public void customize(Server server) {
	ForwardedRequestCustomizer customizer = new ForwardedRequestCustomizer();
	for (Connector connector : server.getConnectors()) {
		for (ConnectionFactory connectionFactory : connector
				.getConnectionFactories()) {
			if (connectionFactory instanceof HttpConfiguration.ConnectionFactory) {
				((HttpConfiguration.ConnectionFactory) connectionFactory)
						.getHttpConfiguration().addCustomizer(customizer);
			}
		}
	}
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:14,代码来源:JettyEmbeddedServletContainerFactory.java

示例3: configureForwardRequestCustomizer

import org.eclipse.jetty.server.ForwardedRequestCustomizer; //导入依赖的package包/类
@VisibleForTesting
HttpConfiguration configureForwardRequestCustomizer(HttpConfiguration httpConf) {
  if (conf.get(HTTP_ENABLE_FORWARDED_REQUESTS_KEY, HTTP_ENABLE_FORWARDED_REQUESTS_DEFAULT)) {
    httpConf.addCustomizer(new ForwardedRequestCustomizer());
  }

  return httpConf;
}
 
开发者ID:streamsets,项目名称:datacollector,代码行数:9,代码来源:WebServerTask.java

示例4: createJetty

import org.eclipse.jetty.server.ForwardedRequestCustomizer; //导入依赖的package包/类
/** Creates a Jetty server listening on HTTP and HTTPS, serving handlers. */
public static Server createJetty(Handler handler)
    throws KeyStoreException, NoSuchAlgorithmException, CertificateException, IOException {
  final Server server = new Server();
  server.setHandler(handler);

  HttpConfiguration httpConfig = new HttpConfiguration();
  // Parses X-Forwarded-For headers for Servlet.getRemoteAddr()
  httpConfig.addCustomizer(new ForwardedRequestCustomizer());

  final ServerConnector connector = new ServerConnector(
      server,
      new HttpConnectionFactory(httpConfig)
  );
  server.addConnector(connector);

  connector.setPort(HTTP_PORT);

  // Enable SSL on port 8443 using the debug keystore
  KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
  InputStream keyStream = Main.class.getResourceAsStream("debug_keystore.jks");
  keyStore.load(keyStream, null);
  keyStream.close();

  SslContextFactory ssl = new SslContextFactory();
  ssl.setKeyStore(keyStore);
  ssl.setKeyStorePassword("password");
  SslConnectionFactory sslFactory = new SslConnectionFactory(ssl, "http/1.1");
  // SecureRequestCustomizer is required to correctly set scheme to https
  HttpConfiguration httpsConfig = new HttpConfiguration();
  httpsConfig.addCustomizer(new SecureRequestCustomizer());
  httpsConfig.addCustomizer(new ForwardedRequestCustomizer());
  ConnectionFactory httpsFactory = new HttpConnectionFactory(httpsConfig);

  ServerConnector sslConnector = new ServerConnector(server, sslFactory, httpsFactory);
  sslConnector.setPort(HTTPS_PORT);
  server.addConnector(sslConnector);

  registerShutdownHook(server);
  return server;
}
 
开发者ID:WeAreWizards,项目名称:passopolis-server,代码行数:42,代码来源:Main.java

示例5: jettyConfigBean

import org.eclipse.jetty.server.ForwardedRequestCustomizer; //导入依赖的package包/类
/**
 * @return Jetty config bean
 */
@Bean
public EmbeddedServletContainerFactory jettyConfigBean() {
	JettyEmbeddedServletContainerFactory jef = new JettyEmbeddedServletContainerFactory();
	jef.addServerCustomizers(new JettyServerCustomizer() {
		public void customize(Server server) {
			if (Config.getConfigBoolean("access_log_enabled", true)) {
				// enable access log via Logback
				HandlerCollection handlers = new HandlerCollection();
				for (Handler handler : server.getHandlers()) {
					handlers.addHandler(handler);
				}
				RequestLogHandler reqLogs = new RequestLogHandler();
				reqLogs.setServer(server);
				RequestLogImpl rli = new RequestLogImpl();
				rli.setResource("/logback-access.xml");
				rli.setQuiet(true);
				rli.start();
				reqLogs.setRequestLog(rli);
				handlers.addHandler(reqLogs);
				server.setHandler(handlers);
			}

			for (Connector y : server.getConnectors()) {
				for (ConnectionFactory cf : y.getConnectionFactories()) {
					if (cf instanceof HttpConnectionFactory) {
						HttpConnectionFactory dcf = (HttpConnectionFactory) cf;
						// support for X-Forwarded-Proto
						// redirect back to https if original request uses it
						if (Config.IN_PRODUCTION) {
							HttpConfiguration httpConfiguration = dcf.getHttpConfiguration();
							httpConfiguration.addCustomizer(new ForwardedRequestCustomizer());
						}
						// Disable Jetty version header
						dcf.getHttpConfiguration().setSendServerVersion(false);
					}
				}
			}
		}
	});
	int defaultPort = NumberUtils.toInt(System.getProperty("jetty.http.port", "8080"));
	jef.setPort(NumberUtils.toInt(System.getProperty("server.port"), defaultPort));
	logger.info("Listening on port {}...", jef.getPort());
	return jef;
}
 
开发者ID:Erudika,项目名称:para,代码行数:48,代码来源:ParaServer.java

示例6: start

import org.eclipse.jetty.server.ForwardedRequestCustomizer; //导入依赖的package包/类
@Override
public void start() throws Exception {
    // Thread pool
    final QueuedThreadPool threadPool = new QueuedThreadPool();
    threadPool.setMinThreads(10);
    threadPool.setMaxThreads(500);

    // Jetty Server
    server = new Server(threadPool);

    // Setup Scheduler
    server.addBean(new ScheduledExecutorScheduler());

    // Setup JMX
    final MBeanContainer mbeanContainer = new MBeanContainer(ManagementFactory.getPlatformMBeanServer());
    server.addBean(mbeanContainer);

    // HTTP config
    final HttpConfiguration httpConfig = new HttpConfiguration();
    httpConfig.addCustomizer( new ForwardedRequestCustomizer() );
    httpConfig.setSecureScheme("https");
    httpConfig.setSecurePort(httpsPort);
    httpConfig.setOutputBufferSize(32768);
    httpConfig.setRequestHeaderSize(8192);
    httpConfig.setResponseHeaderSize(8192);
    httpConfig.setSendServerVersion(false);
    httpConfig.setSendDateHeader(false);

    // HTTP Connector
    final ServerConnector httpConnector = new ServerConnector(server, new HttpConnectionFactory(httpConfig));
    httpConnector.setPort(httpPort);
    httpConnector.setHost(bindInterface);
    httpConnector.setIdleTimeout(30000);
    server.addConnector(httpConnector);

    // Setup handlers
    server.setHandler(createHandlers());

    // Extra config options
    server.setStopAtShutdown(true);

    // Configure SSL
    if (httpsEnable && !Strings.isNullOrEmpty(keystoreFile) && new File(keystoreFile).exists()) {
        // SSL Context
        final SslContextFactory sslContextFactory = new SslContextFactory();
        // Define keystore path and passwords
        sslContextFactory.setKeyStorePath(keystoreFile);
        sslContextFactory.setKeyStorePassword(keystorePassword);
        sslContextFactory.setKeyManagerPassword(keystorePassword);

        // HTTPS config
        final HttpConfiguration httpsConfig = new HttpConfiguration(httpConfig);
        httpsConfig.addCustomizer(new SecureRequestCustomizer());

        // HTTPS connector
        final ServerConnector sslConnector = new ServerConnector(server,
                new SslConnectionFactory(sslContextFactory, "http/1.1"),
                new HttpConnectionFactory(httpsConfig));
        sslConnector.setPort(httpsPort);
        sslConnector.setHost(bindInterface);
        server.addConnector(sslConnector);
    }

    server.start();
    server.join();
}
 
开发者ID:apache,项目名称:cloudstack,代码行数:67,代码来源:ServerDaemon.java


注:本文中的org.eclipse.jetty.server.ForwardedRequestCustomizer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。