Java Code Examples for org.apache.catalina.connector.Connector#setXpoweredBy()

The following examples show how to use org.apache.catalina.connector.Connector#setXpoweredBy() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ServingLayer.java    From oryx with Apache License 2.0 4 votes vote down vote up
private Connector makeConnector() {
  Connector connector = new Connector(Http11Nio2Protocol.class.getName());

  if (keystoreFile == null) {

    // HTTP connector
    connector.setPort(port);
    connector.setSecure(false);
    connector.setScheme("http");

  } else {

    // HTTPS connector
    connector.setPort(securePort);
    connector.setSecure(true);
    connector.setScheme("https");
    connector.setAttribute("SSLEnabled", "true");
    SSLHostConfig sslHostConfig = new SSLHostConfig();
    SSLHostConfigCertificate cert =
        new SSLHostConfigCertificate(sslHostConfig, SSLHostConfigCertificate.Type.RSA);
    cert.setCertificateKeystoreFile(keystoreFile.toAbsolutePath().toString());
    cert.setCertificateKeystorePassword(keystorePassword);
    cert.setCertificateKeyAlias(keyAlias);
    sslHostConfig.addCertificate(cert);
    connector.addSslHostConfig(sslHostConfig);
  }

  connector.addUpgradeProtocol(new Http2Protocol());

  // Keep quiet about the server type
  connector.setXpoweredBy(false);

  // Basic tuning params:
  connector.setAttribute("maxThreads", 400);
  connector.setAttribute("acceptCount", 50);
  //connector.setAttribute("connectionTimeout", 2000);
  connector.setAttribute("maxKeepAliveRequests", 100);

  // Avoid running out of ephemeral ports under heavy load?
  connector.setAttribute("socket.soReuseAddress", true);

  connector.setMaxPostSize(0);
  connector.setAttribute("disableUploadTimeout", false);

  // Allow long URLs
  connector.setAttribute("maxHttpHeaderSize", 65536);

  // Enable response compression
  connector.setAttribute("compression", "on");
  // Defaults are text/html,text/xml,text/plain,text/css
  connector.setAttribute("compressableMimeType", "text/html,text/xml,text/plain,text/css,text/csv,application/json");

  return connector;
}
 
Example 2
Source File: Runner.java    From myrrix-recommender with Apache License 2.0 4 votes vote down vote up
private Connector makeConnector() throws IOException {
  Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol");
  File keystoreFile = config.getKeystoreFile();
  String keystorePassword = config.getKeystorePassword();
  if (keystoreFile == null && keystorePassword == null) {
    // HTTP connector
    connector.setPort(config.getPort());
    connector.setSecure(false);
    connector.setScheme("http");

  } else {

    if (keystoreFile == null || !keystoreFile.exists()) {
      log.info("Keystore file not found; trying to load remote keystore file if applicable");
      ResourceRetriever resourceRetriever =
          ClassUtils.loadInstanceOf("net.myrrix.online.io.DelegateResourceRetriever", ResourceRetriever.class);
      resourceRetriever.init(config.getBucket());
      keystoreFile = resourceRetriever.getKeystoreFile(config.getInstanceID());
      if (keystoreFile == null) {
        throw new FileNotFoundException();
      }
    }

    // HTTPS connector
    connector.setPort(config.getSecurePort());
    connector.setSecure(true);
    connector.setScheme("https");
    connector.setAttribute("SSLEnabled", "true");
    String protocol = chooseSSLProtocol("TLSv1.1", "TLSv1");
    if (protocol != null) {
      connector.setAttribute("sslProtocol", protocol);
    }
    if (keystoreFile != null) {
      connector.setAttribute("keystoreFile", keystoreFile.getAbsoluteFile());
    }
    connector.setAttribute("keystorePass", keystorePassword);
  }

  // Keep quiet about the server type
  connector.setXpoweredBy(false);
  connector.setAttribute("server", "Myrrix");

  // Basic tuning params:
  connector.setAttribute("maxThreads", 400);
  connector.setAttribute("acceptCount", 50);
  //connector.setAttribute("connectionTimeout", 2000);
  connector.setAttribute("maxKeepAliveRequests", 100);

  // Avoid running out of ephemeral ports under heavy load?
  connector.setAttribute("socket.soReuseAddress", true);
  
  connector.setMaxPostSize(0);
  connector.setAttribute("disableUploadTimeout", false);

  return connector;
}