# Keycloak 502 Bad Gateway Issue Upon Angular Application Refresh or Manual URL Change After Authentication

**URL:** <https://forum.keycloak.org/t/keycloak-502-bad-gateway-issue-upon-angular-application-refresh-or-manual-url-change-after-authentication/24332>\
**Category:** Miscellanaeous\
**Created:** [February 1, 2024, 7:40am UTC](https://forum.keycloak.org/t/keycloak-502-bad-gateway-issue-upon-angular-application-refresh-or-manual-url-change-after-authentication/24332 "2024-02-01T07:40:15Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![MukeshAnandan](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/mukeshanandan/32/9667_2.png) [@MukeshAnandan](https://forum.keycloak.org/u/MukeshAnandan)\
**Post date:** [February 1, 2024, 7:40am UTC](https://forum.keycloak.org/t/keycloak-502-bad-gateway-issue-upon-angular-application-refresh-or-manual-url-change-after-authentication/24332/1 "2024-02-01T07:40:15Z")

</div>

I’m encountering difficulties while integrating Keycloak authentication into my Angular application using server configuration by creating respective realms and clients.

Issue I’m facing:

Upon launching the Angular application, it redirects to the keycloak authentication page. After signing in and navigating to the application page, the problem arises when I refresh the page or manually change the application URL. This leads to a keycloak 502 bad gateway issue. However, if I perform a hard refresh on the keycloak authentication page before signing in, everything works fine (both refreshing the page and manually changing the URL).

Please share any insights you may have on this issue or suggestions on how to overcome it.

---

<div class="post-metadata">

**Author:** ![Moha](https://avatars.discourse-cdn.com/v4/letter/m/ecc23a/32.png) [@Moha](https://forum.keycloak.org/u/Moha)\
**Post date:** [February 27, 2024, 10:46am UTC](https://forum.keycloak.org/t/keycloak-502-bad-gateway-issue-upon-angular-application-refresh-or-manual-url-change-after-authentication/24332/2 "2024-02-27T10:46:19Z")

</div>

the same probleme with me 🤒

---

<div class="post-metadata">

**Author:** ![khoutech](https://avatars.discourse-cdn.com/v4/letter/k/a4c791/32.png) [@khoutech](https://forum.keycloak.org/u/khoutech)\
**Post date:** [March 7, 2024, 11:36am UTC](https://forum.keycloak.org/t/keycloak-502-bad-gateway-issue-upon-angular-application-refresh-or-manual-url-change-after-authentication/24332/3 "2024-03-07T11:36:11Z")

</div>

Add these directives to the `http` block in nginx.conf

```auto
proxy_buffer_size 128k;
proxy_buffers 4 256k;
proxy_busy_buffers_size 256k;

```

---

<div class="post-metadata">

**Author:** ![Moha](https://avatars.discourse-cdn.com/v4/letter/m/ecc23a/32.png) [@Moha](https://forum.keycloak.org/u/Moha)\
**Post date:** [March 7, 2024, 5:21pm UTC](https://forum.keycloak.org/t/keycloak-502-bad-gateway-issue-upon-angular-application-refresh-or-manual-url-change-after-authentication/24332/4 "2024-03-07T17:21:44Z")

</div>

wich nginx keycloak or angular  
and me im using k8s for the deployment ??

---

<div class="post-metadata">

**Author:** ![khoutech](https://avatars.discourse-cdn.com/v4/letter/k/a4c791/32.png) [@khoutech](https://forum.keycloak.org/u/khoutech)\
**Post date:** [March 7, 2024, 5:41pm UTC](https://forum.keycloak.org/t/keycloak-502-bad-gateway-issue-upon-angular-application-refresh-or-manual-url-change-after-authentication/24332/5 "2024-03-07T17:41:11Z")

</div>

For those of you that are dealing with Nginx Kubernetes ingress:

```auto
"nginx.ingress.kubernetes.io/proxy-buffer-size": "128k"

```

More info here: [Annotations - Ingress-Nginx Controller](https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/annotations/#proxy-buffer-size)

the answer is in this post: [keycloak - Why do I get 502 when trying to authenticate - Stack Overflow](https://stackoverflow.com/questions/56126864/why-do-i-get-502-when-trying-to-authenticate)
