Interface HttpProxyServerBootstrap
- All Known Implementing Classes:
DefaultHttpProxyServer.DefaultHttpProxyServerBootstrap
HttpProxyServer. The HttpProxyServer is
built using start(). Sensible defaults are available for all
parameters such that start() could be called immediately if you
wish.-
Method Summary
Modifier and TypeMethodDescriptionplusActivityTracker(ActivityTracker activityTracker) Add anActivityTrackerfor tracking activity in this proxy.start()Build and starts the server.withAcceptProxyProtocol(boolean allowProxyProtocol) Specifies if the proxy server should accept a proxy protocol header.withAddress(InetSocketAddress address) Listen for incoming connections on the given address.withAllowLocalOnly(boolean allowLocalOnly) Specify whether or not to only allow local connections.withAllowRequestToOriginServer(boolean allowRequestToOriginServer) When true, the proxy will accept requests that appear to be directed at an origin server (i.e.withAuthenticateSslClients(boolean authenticateSslClients) Specify whether or not to authenticate inbound SSL clients (only applies ifwithSslEngineSource(SslEngineSource)has been set).withChainProxyManager(ChainedProxyManager chainProxyManager) Specify aChainedProxyManagerto use for chaining requests to another proxy.withConnectTimeout(int connectTimeout) Specify the timeout for connecting to the upstream server on a new connection, in milliseconds.withFiltersSource(HttpFiltersSource filtersSource) Specify aHttpFiltersSourceto use for filtering requests and/or responses through this proxy.withIdleConnectionTimeout(int idleConnectionTimeout) Specify the timeout after which to disconnect idle connections, in seconds.withListenOnAllAddresses(boolean listenOnAllAddresses) Deprecated.withManInTheMiddle(MitmManager mitmManager) Specify anMitmManagerto use for making this proxy act as an SSL man in the middlewithMaxChunkSize(int maxChunkSize) withMaxHeaderSize(int maxHeaderSize) withMaxInitialLineLength(int maxInitialLineLength) Give the server a name (used for naming threads, useful for logging).withNetworkInterface(InetSocketAddress inetSocketAddress) All outgoing-communication of the proxy-instance is going' to be routed via the given network-interfacewithPort(int port) Listen for incoming connections on the given port.withProxyAlias(String alias) Sets the alias to use when adding Via headers to incoming and outgoing HTTP messages.withProxyAuthenticator(ProxyAuthenticator proxyAuthenticator) Specify aProxyAuthenticatorto use for doing basic HTTP authentication of clients.withSendProxyProtocol(boolean sendProxyProtocol) Specifies if the proxy server should send a proxy protocol header.withServerGroup(ServerGroup group) Specify a customServerGroupto use for managing this server's resources and such.withServerResolver(HostResolver serverResolver) Specify a customHostResolverfor resolving server addresses.withSslEngineSource(SslEngineSource sslEngineSource) Specify anSslEngineSourceto use for encrypting inbound connections.withThreadPoolConfiguration(ThreadPoolConfiguration configuration) Set the configuration parameters for the proxy's thread pools.withThrottling(long readThrottleBytesPerSecond, long writeThrottleBytesPerSecond) Specify the read and/or write bandwidth throttles for this proxy server.withTransparent(boolean transparent) Specify whether or not to run this proxy as a transparent proxy.withTransportProtocol(TransportProtocol transportProtocol) Specify theTransportProtocolto use for incoming connections.withUseDnsSec(boolean useDnsSec) Specify whether or not to use secure DNS lookups for outbound connections.
-
Method Details
-
withName
Give the server a name (used for naming threads, useful for logging).
Default = LittleProxy
-
withTransportProtocol
Specify the
TransportProtocolto use for incoming connections.Default = TCP
-
withAddress
Listen for incoming connections on the given address.
Default = [bound ip]:8080
-
withPort
Listen for incoming connections on the given port.
Default = 8080
-
withAllowLocalOnly
Specify whether or not to only allow local connections.
Default = true
-
withListenOnAllAddresses
Deprecated.usewithNetworkInterface(InetSocketAddress)to avoid listening on all local addressesThis method has no effect and will be removed in a future release. -
withSslEngineSource
Specify an
SslEngineSourceto use for encrypting inbound connections. Enabling this will enable SSL client authentication by default (seewithAuthenticateSslClients(boolean))Default = null
Note - This and
withManInTheMiddle(MitmManager)are mutually exclusive. -
withAuthenticateSslClients
Specify whether or not to authenticate inbound SSL clients (only applies if
withSslEngineSource(SslEngineSource)has been set).Default = true
-
withProxyAuthenticator
Specify a
ProxyAuthenticatorto use for doing basic HTTP authentication of clients.Default = null
-
withChainProxyManager
Specify a
ChainedProxyManagerto use for chaining requests to another proxy.Default = null
-
withManInTheMiddle
Specify an
MitmManagerto use for making this proxy act as an SSL man in the middleDefault = null
Note - This and
withSslEngineSource(SslEngineSource)are mutually exclusive. -
withFiltersSource
Specify a
HttpFiltersSourceto use for filtering requests and/or responses through this proxy.Default = null
-
withUseDnsSec
Specify whether or not to use secure DNS lookups for outbound connections.
Default = false
-
withTransparent
Specify whether or not to run this proxy as a transparent proxy.
Default = false
-
withIdleConnectionTimeout
Specify the timeout after which to disconnect idle connections, in seconds.
Default = 70
-
withConnectTimeout
Specify the timeout for connecting to the upstream server on a new connection, in milliseconds.
Default = 40000
-
withServerResolver
Specify a customHostResolverfor resolving server addresses. -
withServerGroup
Specify a customServerGroupto use for managing this server's resources and such. If one isn't provided, a default one will be created using theThreadPoolConfigurationprovided- Parameters:
group- A custom server group
-
plusActivityTracker
Add an
ActivityTrackerfor tracking activity in this proxy. -
withThrottling
HttpProxyServerBootstrap withThrottling(long readThrottleBytesPerSecond, long writeThrottleBytesPerSecond) Specify the read and/or write bandwidth throttles for this proxy server. 0 indicates not throttling.
-
withNetworkInterface
All outgoing-communication of the proxy-instance is going' to be routed via the given network-interface- Parameters:
inetSocketAddress- to be used for outgoing communication
-
withMaxInitialLineLength
-
withMaxHeaderSize
-
withMaxChunkSize
-
withAllowRequestToOriginServer
When true, the proxy will accept requests that appear to be directed at an origin server (i.e. the URI in the HTTP request will contain an origin-form, rather than an absolute-form, as specified in RFC 7230, section 5.3). This is useful when the proxy is acting as a gateway/reverse proxy. Note: This feature should not be enabled when running as a forward proxy; doing so may cause an infinite loop if the client requests the URI of the proxy.- Parameters:
allowRequestToOriginServer- when true, the proxy will accept origin-form HTTP requests
-
withProxyAlias
Sets the alias to use when adding Via headers to incoming and outgoing HTTP messages. The alias may be any pseudonym, or if not specified, defaults to the hostname of the local machine. See RFC 7230, section 5.7.1.- Parameters:
alias- the pseudonym to add to Via headers
-
start
HttpProxyServer start()Build and starts the server.
- Returns:
- the newly built and started server
-
withThreadPoolConfiguration
Set the configuration parameters for the proxy's thread pools.- Parameters:
configuration- thread pool configuration- Returns:
- proxy server bootstrap for chaining
-
withAcceptProxyProtocol
Specifies if the proxy server should accept a proxy protocol header. Once set it works with request that include a proxy protocol header. The proxy server reads an incoming proxy protocol header from the client.- Parameters:
allowProxyProtocol- when true, the proxy will accept a proxy protocol header
-
withSendProxyProtocol
Specifies if the proxy server should send a proxy protocol header.- Parameters:
sendProxyProtocol- when true, the proxy will send a proxy protocol header
-
withNetworkInterface(InetSocketAddress)to avoid listening on all local addresses