# Openid connect and reverse proxy

**URL:** <https://forum.search-guard.com/t/openid-connect-and-reverse-proxy/2250>\
**Category:** Search Guard\
**Created:** [November 26, 2021, 3:01pm UTC](https://forum.search-guard.com/t/openid-connect-and-reverse-proxy/2250 "2021-11-26T15:01:10Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![zdenek](https://avatars.discourse-cdn.com/v4/letter/z/5f8ce5/32.png) [@zdenek](https://forum.search-guard.com/u/zdenek)\
**Post date:** [November 26, 2021, 3:01pm UTC](https://forum.search-guard.com/t/openid-connect-and-reverse-proxy/2250/1 "2021-11-26T15:01:10Z")

</div>

Hi, we try to configure SSO for kibana, we use Microsoft ADFS and openid. We also use an apache reverse proxy for our kibana and we have the kibana server.basePath parameter set.  
When we configure openid for kibana sso login process stops at URL [https://ourdomain/ourbasepath/auth/openid/encode?nextUrl=%2Fourbasepath%2F](https://ourdomain/ourbasepath/auth/openid/encode?nextUrl=%2Fourbasepath%2F)

source code of encode is

```auto
          <html>
            <head>
            <script src="/auth/openid/encode-js"></script>
            </head>
            <body></body>
          </html>

```

As you can see the basepath is missing in src of encode-js script, script isn’t loaded and the login process stops here.

We found the source javascript of this URL in routes.js and it seems like the base path is not used in

```auto
httpResources.register({
  path: `${_constants.APP_ROOT}${routesPath}encode-js`,

```

When we use LDAP or SAML everything works well. But we need to configure openid.  
Can you please check the whole login process for openid when a reverse proxy is used?  
And make a fixed version or let us know how to fix this behavior?

**Elasticsearch version:**  
7.15.

**Server OS version:**  
RHEL 7

**Kibana version (if relevant):**  
7.15.1 and 7.10.2 we try both

**Describe the issue:**  
Login process stops at URL: [https://ourdomain/ourbasepath/auth/openid/encode?nextUrl=%2Fourbasepath%2F](https://ourdomain/ourbasepath/auth/openid/encode?nextUrl=%2Fourbasepath%2F)

**Steps to reproduce:**

1. configure apache reverse proxy server for kibana
2. configure kibana with server.basePath parameter
3. configure openid sso in kibana
4. try to login

**Expected behavior:**  
The login process will work.

---

<div class="post-metadata">

**Author:** ![pablo](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.search-guard.com/pablo/32/1443_2.png) [@pablo](https://forum.search-guard.com/u/pablo)\
**Post date:** [November 29, 2021, 9:15am UTC](https://forum.search-guard.com/t/openid-connect-and-reverse-proxy/2250/2 "2021-11-29T09:15:02Z")

</div>

Hello @zdenek

Would you mind sharing your kibana.yml and sg\_config.yml files?

---

<div class="post-metadata">

**Author:** ![system](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.search-guard.com/system/32/1870_2.png) [@system](https://forum.search-guard.com/u/system)\
**Post date:** [December 20, 2021, 9:15am UTC](https://forum.search-guard.com/t/openid-connect-and-reverse-proxy/2250/3 "2021-12-20T09:15:24Z")

</div>

Closed on December 20, 2021, 9:15am UTC

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

---

<div class="post-metadata">

**Author:** ![pablo](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.search-guard.com/pablo/32/1443_2.png) [@pablo](https://forum.search-guard.com/u/pablo)\
**Post date:** [December 31, 2021, 3:23pm UTC](https://forum.search-guard.com/t/openid-connect-and-reverse-proxy/2250/4 "2021-12-31T15:23:12Z")

</div>

@zdenek Thanks for providing the files.

I’ve found that in my case I had to set the below in kibana.yml to get it working with keycloak OpenID.

```auto
server.basePath: "/basePath"
searchguard.openid.base_redirect_url: "https://<haproxy_FQDN>"

```

In keycloak my redirect is set to “https://\<haproxy\_FQDN\>/basePath”

In haproxy.cfg I have the below.

```auto
backend kibana1 
    option httpchk GET /api/status HTTP/1.1\r\nHost:localhost
    reqrep ^([^\ :]*)\ /kibana1(\/*)(.*) \1\ /\3
    rsprep ^[Cc]ache-[Cc]ontrol:\ no-cache Cache-Control:\ max-age=84600 if { capture.req.uri -m beg /kibana1/ui/ /kibana1/plugins/ /kibana1/bundles/ }
    server kibana1 <FQDN_of_destination_kibana>:5601 check ssl verify none

```

In your case `basePath` is present in both `server.basePath` and `searchguard.openid.base_redirect_url:`

---

<div class="post-metadata">

**Author:** ![pablo](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.search-guard.com/pablo/32/1443_2.png) [@pablo](https://forum.search-guard.com/u/pablo)\
**Post date:** [December 31, 2021, 4:27pm UTC](https://forum.search-guard.com/t/openid-connect-and-reverse-proxy/2250/5 "2021-12-31T16:27:40Z")

</div>

Opened on December 31, 2021, 4:27pm UTC



---

<div class="post-metadata">

**Author:** ![zdenek](https://avatars.discourse-cdn.com/v4/letter/z/5f8ce5/32.png) [@zdenek](https://forum.search-guard.com/u/zdenek)\
**Post date:** [January 24, 2022, 9:24am UTC](https://forum.search-guard.com/t/openid-connect-and-reverse-proxy/2250/6 "2022-01-24T09:24:59Z")

</div>

@pablo  
Hi,  
we try to configure `searchguard.openid.base_redirect_url: "https://kibana.csint.cz/notix" ` and also `searchguard.openid.base\_redirect\_url: “[https://kibana.csint.cz](https://kibana.csint.cz)” but behavior is still same.  
Authentication process stops at URL [https://kibana.csint.cz/notix/auth/openid/encode?nextUrl=%2Fnotix%2F](https://kibana.csint.cz/notix/auth/openid/encode?nextUrl=%2Fnotix%2F) because try to load the script at URL “[https://kibana.csint.cz/auth/openid/encode-js”](https://kibana.csint.cz/auth/openid/encode-js%E2%80%9D) and the script doesn’t exist.  
I make a screenshot from my browser.  
Can you tell us what we can try?

 ![Screenshot_searchguard_openid](https://us1.discourse-cdn.com/flex019/uploads/search_guard/original/2X/2/2c73e57601f22481fd1ee66866d6c6ac660f2e50.png)

---

<div class="post-metadata">

**Author:** ![nils](https://avatars.discourse-cdn.com/v4/letter/n/d6d6ee/32.png) [@nils](https://forum.search-guard.com/u/nils)\
**Post date:** [February 23, 2022, 7:09am UTC](https://forum.search-guard.com/t/openid-connect-and-reverse-proxy/2250/7 "2022-02-23T07:09:51Z")

</div>

We have just released a new version of Search Guard which fixes the issue:

> [@New release: Search Guard 53](https://forum.search-guard.com/t/new-release-search-guard-53/2290):
>
> Now available: Search Guard 53. Search Guard 53 brings support for ES 7.17.0, additional functionality for JWT authentication, and bug fixes for OIDC login and Signals. JWT: The JWT authenticator now allows you to specify expected values for audience and/or issuer claims. If one of these values is specified, a JWT will be only accepted if the value matches. OIDC Login: The new OIDC redirect handling implemented in Search Guard 51.0 caused issues with many Identity Providers, as it required th…
