You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by kevdoran <gi...@git.apache.org> on 2018/05/07 18:23:37 UTC

[GitHub] nifi pull request #2683: NIFI-5146 Only support HTTP or HTTPS operation for ...

Github user kevdoran commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/2683#discussion_r186499568
  
    --- Diff: nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-jetty/src/main/java/org/apache/nifi/web/server/JettyServer.java ---
    @@ -601,106 +601,144 @@ private void configureConnectors(final Server server) throws ServerConfiguration
             httpConfiguration.setRequestHeaderSize(headerSize);
             httpConfiguration.setResponseHeaderSize(headerSize);
     
    -        if (props.getPort() != null) {
    -            final Integer port = props.getPort();
    -            if (port < 0 || (int) Math.pow(2, 16) <= port) {
    -                throw new ServerConfigurationException("Invalid HTTP port: " + port);
    -            }
    +        // Check if both HTTP and HTTPS connectors are configured and fail if both are configured
    +        if (bothHttpAndHttpsConnectorsConfigured(props)) {
    +            logger.error("NiFi only supports one mode of HTTP or HTTPS operation, not both simultaneously. " +
    +                    "Check the nifi.properties file and ensure that either the HTTP hostname and port or the HTTPS hostname and port are empty");
    +            startUpFailure(new IllegalStateException("Only one of the HTTP and HTTPS connectors can be configured at one time"));
    +        }
     
    -            logger.info("Configuring Jetty for HTTP on port: " + port);
    +        if (props.getSslPort() != null) {
    +            configureHttpsConnector(server, httpConfiguration);
    +        } else if (props.getPort() != null) {
    +            configureHttpConnector(server, httpConfiguration);
    +        } else {
    +            logger.error("Neither the HTTP nor HTTPS connector was configured in nifi.properties");
    +            startUpFailure(new IllegalStateException("Must configure HTTP or HTTPS connector"));
    +        }
    +    }
     
    -            final List<Connector> serverConnectors = Lists.newArrayList();
    +    /**
    +     * Configures an HTTPS connector and adds it to the server.
    +     *
    +     * @param server the Jetty server instance
    +     * @param httpConfiguration the configuration object for the HTTPS protocol settings
    +     */
    +    private void configureHttpsConnector(Server server, HttpConfiguration httpConfiguration) {
    +        String hostname = props.getProperty(NiFiProperties.WEB_HTTP_HOST);
    --- End diff --
    
    Unless I'm missing something, this should be `NiFiProperties.WEB_HTTPS_HOST`


---