# Keycloak With Nextcloud

**URL:** <https://forum.keycloak.org/t/keycloak-with-nextcloud/17080>\
**Category:** Configuring the server\
**Created:** [August 24, 2022, 5:45pm UTC](https://forum.keycloak.org/t/keycloak-with-nextcloud/17080 "2022-08-24T17:45:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![zohaib09](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/zohaib09/32/6426_2.png) [@zohaib09](https://forum.keycloak.org/u/zohaib09)\
**Post date:** [August 24, 2022, 5:45pm UTC](https://forum.keycloak.org/t/keycloak-with-nextcloud/17080/1 "2022-08-24T17:45:13Z")

</div>

Hi

I have just installed keycloak. Now i want to configure it with NC as a SSO. I am using openid Connect backend to connect it

SSL configuration

In conf folder of keycloak generated keystore as

keytool -genkeypair -alias sso.mydomain.cloud -keyalg RSA -keysize 2048 -validity 1825 -keystore server.keystore -dname “cn=sso.mydomain.cloud,o=Acme,c=GB” -keypass password -storepass password

in keycloak.conf, described only following lines

proxy=edge

http-enabled=true

http-port=8180

hostname=sso.mydomain.cloud

Then configure reverse proxy in apache with following config

VirtualHost \*:80\>  
ServerName sso.mydomain.cloud

# AllowEncodedSlashes NoDecode

ProxyPreserveHost On

# RequestHeader set X-Forwarded-Proto “https”

# RequestHeader set X-Forwarded-Port “443”

SSLProxyEngine on  
ProxyPassReverse / [https://127.0.0.1:8443/](https://127.0.0.1:8443/)  
ProxyPass / [https://127.0.0.1:8443/](https://127.0.0.1:8443/)  
\</VirtualHost  
Then run certbot command to generate ssl certificate for my sso domain.

Then start keycloak as

./kc.sh start --https-key-store-password=password

This is my configuration at NC

 ![image](https://global.discourse-cdn.com/free1/uploads/keycloak/original/2X/6/6e2ca78534d57adee8635f0e3fbd4c03aa56444e.png)

When i click on SSO login i get this error on NC:

Could not the reach OpenID Connect provider

Could not reach provider at URLhttps://sso.mydomain.com/realms/SSO/protocol/openid-connect/auth

Error at keycloak

dolphinslairapps kc.sh[829823]: 2022-08-24 15:46:24,366 WARN [org.keycloak.events] (executor-thread-9) type=LOGIN\_ERROR, realmId=62ac84de-b7f3-4823-a24e-bc5d4a1e9c5b, clientId=null, userId=null, ipAddress=IP, error=invalid\_request

---

<div class="post-metadata">

**Author:** ![gsmith](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/gsmith/32/294_2.png) [@gsmith](https://forum.keycloak.org/u/gsmith)\
**Post date:** [August 26, 2022, 4:53am UTC](https://forum.keycloak.org/t/keycloak-with-nextcloud/17080/2 "2022-08-26T04:53:04Z")

</div>

hello,

> [@zohaib09](#):
>
> openid Connect backend to connect it

Im running Nextcloud 24.0.3, I haven’t used Open ID I used SAML. No problems

This worked for me with a couple adjustments.

- [Janik von Rotz - Configure SAML Authentication for Nextcloud with Keycloack](https://janikvonrotz.ch/2020/04/21/configure-saml-authentication-for-nextcloud-with-keycloack/)

---

<div class="post-metadata">

**Author:** ![tomz](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/tomz/32/6499_2.png) [@tomz](https://forum.keycloak.org/u/tomz)\
**Post date:** [September 6, 2022, 9:09am UTC](https://forum.keycloak.org/t/keycloak-with-nextcloud/17080/3 "2022-09-06T09:09:07Z")

</div>

Have you tried to hit your url via curl? Like so:

> curl -v [https://sso.mydomain.com/admin/master/console/](https://sso.mydomain.com/admin/master/console/)

If the URL works you should get some keycloak generated html text back.

Alternatively I can share my working setup with NC + [GitHub - pulsejet/nextcloud-oidc-login: Nextcloud login via a single OpenID Connect 1.0 provider](https://github.com/pulsejet/nextcloud-oidc-login) and KC19.0.1  
This is the related section in my config.php:

```auto
  'oidc_login_client_id' => 'Nextcloud',
  'oidc_login_client_secret' => 'mysecrect',
  'oidc_login_provider_url' => 'https://iam.mydomain.com/realms/myclient',
  'oidc_login_logout_url' => 'https://iam.mydomain.com/realms/myclient/protocol/openid-connect/logout?redirect_uri=https%3A%2F%2Fcloud.mydomain.com%2F',
  'oidc_login_auto_redirect' => true,
  'oidc_login_redir_fallback' => true,
  'oidc_login_attributes' =>
  array (
    'id' => 'preferred_username',
    'mail' => 'email',
    'groups' => 'ownCloudGroups',
  ),

```
