1

我正在使用 apache httpcore 库来监听 http 请求,如下所示。

IOReactorConfig config = IOReactorConfig.custom() // Create instance of a custom Builder
                    .setTcpNoDelay(true) //
                    // Enable/disable SO_TIMEOUT with the specified timeout, in milliseconds. InputStream associated
                    // with this Socket will block for only this amount of time. If the timeout expires, a
                    // java.net.SocketTimeoutException
                    // is raised, though the Socket is still valid. The option must be enabled prior to entering the
                    // blocking operation to have effect. The timeout must be > 0. A timeout of zero is interpreted
                    // as an infinite timeout.
                    .setSoTimeout(PropertiesStorage.getCcsSocketTimeoutMilis()) //
                    .setSoReuseAddress(true) //
                    .setConnectTimeout(PropertiesStorage.getCcsConnectionTimeoutMilis()) //
                    // Determines the number of I/O dispatch threads to be used by the I/O reactor.
                    .setIoThreadCount(PropertiesStorage.getCcsDispatchThreadCount()) //
                    .build();

// Create instance of a server - reactor
private static ListeningIOReactor ioReactor = new  DefaultListeningIOReactor(config);

// Listening on specific port
ioReactor.listen(new InetSocketAddress(SERVER_IP, SERVER_PORT));

我想配置 mod_reqtimeout、mod_qos 和 mod_security,以防止“缓慢拒绝服务”。但我不确定如何配置这些参数。你能帮忙吗?

4

0 回答 0