Skip to content

Commit a28a6a3

Browse files
authored
Improve proxy configuration docs (#2035)
1 parent 78cc262 commit a28a6a3

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

docs/connecting.asciidoc

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -539,11 +539,17 @@ If you need to pass through an http(s) proxy for connecting to {es}, the client
539539
out of the box offers a handy configuration for helping you with it. Under the
540540
hood, it uses the https://github.com/delvedor/hpagent[`hpagent`] module.
541541

542+
In versions 8.0+ of the client, the default `Connection` type is set to `UndiciConnection`, which does not support proxy configurations.
543+
To use a proxy, you will need to use the `HttpConnection` class from `@elastic/transport` instead.
544+
542545
[source,js]
543546
----
547+
import { HttpConnection } from '@elastic/transport'
548+
544549
const client = new Client({
545550
node: 'http://localhost:9200',
546-
proxy: 'http://localhost:8080'
551+
proxy: 'http://localhost:8080',
552+
Connection: HttpConnection,
547553
})
548554
----
549555

@@ -553,11 +559,12 @@ Basic authentication is supported as well:
553559
----
554560
const client = new Client({
555561
node: 'http://localhost:9200',
556-
proxy: 'http:user:pwd@//localhost:8080'
562+
proxy: 'http:user:pwd@//localhost:8080',
563+
Connection: HttpConnection,
557564
})
558565
----
559566

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

563570
[source,js]
@@ -567,7 +574,8 @@ const client = new Client({
567574
node: 'http://localhost:9200',
568575
agent () {
569576
return new SocksProxyAgent('socks://127.0.0.1:1080')
570-
}
577+
},
578+
Connection: HttpConnection,
571579
})
572580
----
573581

0 commit comments

Comments
 (0)