Skip to content

Commit

Permalink
Improve proxy configuration docs (#2035)
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshMock committed Oct 24, 2023
1 parent 10d4d18 commit 8619f28
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions docs/connecting.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -539,11 +539,17 @@ If you need to pass through an http(s) proxy for connecting to {es}, the client
out of the box offers a handy configuration for helping you with it. Under the
hood, it uses the https://github.com/delvedor/hpagent[`hpagent`] module.

In versions 8.0+ of the client, the default `Connection` type is set to `UndiciConnection`, which does not support proxy configurations.
To use a proxy, you will need to use the `HttpConnection` class from `@elastic/transport` instead.

[source,js]
----
import { HttpConnection } from '@elastic/transport'
const client = new Client({
node: 'http://localhost:9200',
proxy: 'http://localhost:8080'
proxy: 'http://localhost:8080',
Connection: HttpConnection,
})
----

Expand All @@ -553,11 +559,12 @@ Basic authentication is supported as well:
----
const client = new Client({
node: 'http://localhost:9200',
proxy: 'http:user:pwd@//localhost:8080'
proxy: 'http:user:pwd@//localhost:8080',
Connection: HttpConnection,
})
----

If you are connecting through a not http(s) proxy, such as a `socks5` or `pac`,
If you are connecting through a non-http(s) proxy, such as a `socks5` or `pac`,
you can use the `agent` option to configure it.

[source,js]
Expand All @@ -567,7 +574,8 @@ const client = new Client({
node: 'http://localhost:9200',
agent () {
return new SocksProxyAgent('socks://127.0.0.1:1080')
}
},
Connection: HttpConnection,
})
----

Expand Down

0 comments on commit 8619f28

Please sign in to comment.