# Elasticsearch OIDC connection through Proxy

**URL:** <https://discuss.elastic.co/t/elasticsearch-oidc-connection-through-proxy/223018>\
**Category:** Elasticsearch\
**Created:** [March 10, 2020, 8:49pm UTC](https://discuss.elastic.co/t/elasticsearch-oidc-connection-through-proxy/223018 "2020-03-10T20:49:13Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chris\_Samo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/chris_samo/32/46830_2.png) [@Chris\_Samo](https://discuss.elastic.co/u/Chris_Samo)\
**Post date:** [March 10, 2020, 8:49pm UTC](https://discuss.elastic.co/t/elasticsearch-oidc-connection-through-proxy/223018/1 "2020-03-10T20:49:13Z")

</div>

We use an OpenID Connect provider for Authentication & Authorisation in Elasticsearch, however have been tasked with locking down egress from our cluster (we're running in Kubernetes using Docker images).

We've implemented a proxy through which we'd like traffic to be directed and while this appears to have worked for our SLM connection to S3, we're unable to connect through Kibana to Elasticsearch using the OIDC realm because the connection to our OIDC Provider times out with log output similar to:

> {"type": "server", "timestamp": "2020-03-10T20:23:35,364Z", "level": "WARN", "component": "o.e.x.s.a.AuthenticationService", "cluster.name": "my-elasticsearch", "node.name": "elasticsearch-1.elasticsearch-hs.my.svc.cluster.local", "message": "Authentication to realm kibana failed - Failed to authenticate user with OpenID Connect (Caused by ElasticsearchSecurityException[Failed to exchange code for Id Token using the Token Endpoint.]; nested: ConnectException[Timeout connecting to [[my.oidc.provider.co.uk/1.2.3.4:443](http://my.oidc.provider.co.uk/1.2.3.4:443)]];)", "cluster.uuid": "abcdef", "node.id": "12345" }

I can see from our proxy logs that while other components are successfully directing traffic through to the OIDC Provider, nothing ever appears from Elasticsearch, instead it appear to be trying to connect directly.

I've set the following (typical) environment variables:

- HTTP\_PROXY (our proxy)
- HTTPS\_PROXY (our proxy)
- NO\_PROXY (localhost and intra-cluster services)

I also tried setting the lowercase variants of these same variables. Finally, I've tried adding the Java flags to the jvm.options file:

- -Dhttp.proxyHost=
- -Dhttp.proxyPort=
- -Dhttps.proxyHost=
- -Dhttps.proxyPort=
- -Dhttp.nonProxyHosts=

We're using Elasticsearch 7.6.0. Is it just that the OIDC classes fail to pay attention to proxy settings or are we missing something?

---

<div class="post-metadata">

**Author:** ![Chris\_Samo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/chris_samo/32/46830_2.png) [@Chris\_Samo](https://discuss.elastic.co/u/Chris_Samo)\
**Post date:** [March 10, 2020, 9:43pm UTC](https://discuss.elastic.co/t/elasticsearch-oidc-connection-through-proxy/223018/2 "2020-03-10T21:43:42Z")

</div>

Is this to do with the oidc provider setting up its own http client ([https://github.com/elastic/elasticsearch/blob/master/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/oidc/OpenIdConnectAuthenticator.java#L566](https://github.com/elastic/elasticsearch/blob/master/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/oidc/OpenIdConnectAuthenticator.java#L566)), but not paying attention to properties using a method like [http://hc.apache.org/httpcomponents-asyncclient-dev/httpasyncclient/apidocs/org/apache/http/impl/nio/client/HttpAsyncClientBuilder.html](http://hc.apache.org/httpcomponents-asyncclient-dev/httpasyncclient/apidocs/org/apache/http/impl/nio/client/HttpAsyncClientBuilder.html)?

I've only had a quick look at the code, so may well have missed the mark

---

<div class="post-metadata">

**Author:** ![ikakavas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ikakavas/32/34430_2.png) [@ikakavas](https://discuss.elastic.co/u/ikakavas)\
**Post date:** [March 11, 2020, 4:54am UTC](https://discuss.elastic.co/t/elasticsearch-oidc-connection-through-proxy/223018/3 "2020-03-11T04:54:13Z")

</div>

You are right, we don't expose proxy settings configuration for the OpenID Connect realm related outgoing communications ( SLM and S3 works because the s3 repository plugin [does have relevant configuration](https://www.elastic.co/guide/en/elasticsearch/plugins/current/repository-s3-client.html).

I raised [https://github.com/elastic/elasticsearch/issues/53379](https://github.com/elastic/elasticsearch/issues/53379) to track this

---

<div class="post-metadata">

**Author:** ![Chris\_Samo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/chris_samo/32/46830_2.png) [@Chris\_Samo](https://discuss.elastic.co/u/Chris_Samo)\
**Post date:** [March 11, 2020, 6:01am UTC](https://discuss.elastic.co/t/elasticsearch-oidc-connection-through-proxy/223018/4 "2020-03-11T06:01:53Z")

</div>

Darn, but thanks for confirming. We'll figure something for a workaround in the meantime and keep a watch on the issue.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [April 8, 2020, 6:01am UTC](https://discuss.elastic.co/t/elasticsearch-oidc-connection-through-proxy/223018/5 "2020-04-08T06:01:53Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
