Provides a ConnectionSocketFactory
that injects a PROXY protocol header (v1) when opening a connection.
Add the dependency:
<dependencies>
<dependency>
<groupId>io.github.jmkeyes</groupId>
<artifactId>httpclient-proxy-protocol</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
Register the ProxyProtocolConnectionSocketFactory
:
Registry<ConnectionSocketFactory> registry = RegistryBuilder.<ConnectionSocketFactory>create()
.register("http", new ProxyProtocolConnectionSocketFactory(new PlainConnectionSocketFactory())
.register("https", new ProxyProtocolConnectionSocketFactory(new SSLConnectionSocketFactory(sslContext)));
.build();
PoolingHttpClientConnectionManager connectionManager = new PoolingHttpCLientConnectionManager(registry);
HttpClient client = HttpClients.custom()
.setConnectionManager(connectionManager)
.build();
Now whenever client
creates a new connection it will send the PROXY header automatically.
- Clone this repository.
- Create your branch:
git checkout -b feature/branch
- Commit your changes:
git commit -am "I am developer."
- Push your changes:
git push origin feature/branch
- Create a PR of your branch against the
master
branch.