Class ProxyServer

java.lang.Object
io.fluxzero.proxy.ProxyServer

public class ProxyServer extends Object
  • Field Details

    • DEFAULT_MAX_REQUEST_BODY_SIZE

      public static final long DEFAULT_MAX_REQUEST_BODY_SIZE
      Default maximum request body size: 256 MiB
      See Also:
    • DEFAULT_MAX_MULTIPART_REQUEST_BODY_SIZE

      public static final long DEFAULT_MAX_MULTIPART_REQUEST_BODY_SIZE
      Default maximum multipart request body size: 1 GiB
      See Also:
    • DEFAULT_MAX_HEADER_SIZE

      public static final int DEFAULT_MAX_HEADER_SIZE
      Default maximum request and response header size: 1 MiB
      See Also:
    • DEFAULT_RESPONSE_HEADER_BUFFER_SIZE

      public static final int DEFAULT_RESPONSE_HEADER_BUFFER_SIZE
      Default initial response header buffer capacity: 8 KiB
      See Also:
    • DEFAULT_IDLE_TIMEOUT_MILLIS

      public static final long DEFAULT_IDLE_TIMEOUT_MILLIS
      Default connector idle timeout: 60 seconds
      See Also:
    • DEFAULT_MAX_THREADS

      public static final int DEFAULT_MAX_THREADS
      Default Jetty maximum platform thread count.
      See Also:
    • DEFAULT_MIN_THREADS

      public static final int DEFAULT_MIN_THREADS
      Default Jetty minimum platform thread count.
      See Also:
    • DEFAULT_MAX_IN_FLIGHT_WEB_REQUESTS

      public static final int DEFAULT_MAX_IN_FLIGHT_WEB_REQUESTS
      Default maximum in-flight web requests accepted by the proxy. A value of 0 disables this guardrail.
      See Also:
    • DEFAULT_MAX_PENDING_WEBSOCKET_SENDS

      public static final int DEFAULT_MAX_PENDING_WEBSOCKET_SENDS
      Default maximum queued outgoing websocket sends per session.
      See Also:
    • DEFAULT_WEBSOCKET_IDLE_TIMEOUT_MILLIS

      public static final long DEFAULT_WEBSOCKET_IDLE_TIMEOUT_MILLIS
      Default websocket idle timeout: 120 seconds
      See Also:
    • DEFAULT_WEBSOCKET_PING_DELAY_MILLIS

      public static final long DEFAULT_WEBSOCKET_PING_DELAY_MILLIS
      Default delay between proxy websocket keep-alive pings: 55 seconds
      See Also:
    • DEFAULT_WEBSOCKET_PING_TIMEOUT_MILLIS

      public static final long DEFAULT_WEBSOCKET_PING_TIMEOUT_MILLIS
      Default time allowed for receiving a proxy websocket keep-alive pong: 10 seconds
      See Also:
    • RESPONSE_HEADER_BUFFER_SIZE_PROPERTY

      public static final String RESPONSE_HEADER_BUFFER_SIZE_PROPERTY
      Initial response header buffer capacity in bytes. The environment variable is FLUXZERO_PROXY_RESPONSE_HEADER_BUFFER_SIZE. The default is 8 KiB. This controls header buffering, not response body size or the maximum accepted header size. Larger headers use Jetty's overflow path up to the separately configured maximum.
      See Also:
    • USE_OUTPUT_DIRECT_BYTE_BUFFERS_PROPERTY

      public static final String USE_OUTPUT_DIRECT_BYTE_BUFFERS_PROPERTY
      Whether Jetty uses direct buffers for HTTP output. The environment variable is FLUXZERO_PROXY_USE_OUTPUT_DIRECT_BYTE_BUFFERS. Disable this to account output buffers on the Java heap. The default is true.
      See Also:
    • HTTP2_MAX_RESPONSE_HEADER_SIZE_PROPERTY

      public static final String HTTP2_MAX_RESPONSE_HEADER_SIZE_PROPERTY
      Maximum HTTP/2 response-header list size in bytes. The environment variable is FLUXZERO_PROXY_HTTP2_MAX_RESPONSE_HEADER_SIZE. The default is 16 KiB, independently of fluxzero.defaults.version. An explicit positive value overrides this default. The shared response maximum and the peer's advertised maximum still cap this value. HTTP/1 headers and incoming requests are unaffected.
      See Also:
  • Constructor Details

    • ProxyServer

      protected ProxyServer(ProxyRequestHandler proxyHandler, org.eclipse.jetty.server.Server server, int port, io.fluxzero.common.Registration shutdownRegistration, Runnable forceShutdown, io.fluxzero.common.Registration ownedClientShutdown, boolean gracefulShutdown, AtomicReference<io.fluxzero.proxy.ProxyServer.LifecycleState> lifecycleState, Duration drainDelay, Duration shutdownTimeout)
  • Method Details

    • main

      public static void main(String[] args)
      Standalone process entry point.

      Do not call this method to embed the proxy in another application. Use start() instead so the caller owns the proxy lifecycle and shutdown order.

    • start

      public static ProxyServer start()
      Starts an embedded proxy server using the configured port and runtime base URL.

      The port is resolved from FLUXZERO_PROXY_PORT, PROXY_PORT, or 8080, in that order. The Fluxzero runtime URL is resolved from FLUXZERO_BASE_URL, FLUX_BASE_URL, or FLUX_URL, in that order. The returned server owns the created Fluxzero client and forward proxy consumer; callers should stop all embedded proxy resources by calling cancel().

      This method does not register a JVM shutdown hook, create a Fluxzero keepalive thread, or set a global Fluxzero application instance. Use main(String[]) for standalone process startup.

      Returns:
      a ProxyServer instance representing the started proxy server and owned embedded resources
    • start

      public static ProxyServer start(ProxyServerConfig config)
      Starts an embedded proxy server with explicit configuration.

      The returned server owns the created Fluxzero client and forward proxy consumer; callers should stop all embedded proxy resources by calling cancel().

      Parameters:
      config - proxy server configuration
      Returns:
      a ProxyServer instance representing the started proxy server and owned embedded resources
    • start

      public static ProxyServer start(ProxyServerConfig config, String host)
      Starts an embedded proxy on an explicit interface, with the port and backend settings from config. Use "127.0.0.1" for isolated loopback tests; other overloads retain their all-interface binding. The returned proxy owns its client and forward consumer and must be stopped with cancel().
      Parameters:
      config - proxy configuration
      host - interface address to bind
      Returns:
      the started proxy
    • isReady

      public boolean isReady()
      Returns whether the proxy has reached runtime readiness and is not draining.
    • cancel

      public void cancel()
    • merge

      default io.fluxzero.common.Registration merge(io.fluxzero.common.Registration arg0)