how to make sure url instead of ip address is sent for oAuth?

Hi
I want to connect my selfhosted erpnext with authentik (OAuth2/OpenID Provider) for Single-Sign Log-in. I followed the integration guideline of authentik for all frappe projects Integrate with Frappe Helpdesk | authentik

Now I have a problem with the redirect url that is sent from erpnext to authentik.
Error message in authentik: “The request fails due to a missing, invalid, or mismatching redirection URI (redirect_uri).”

I see that in the redirect url erpnext provides its own local IP address (192.168…) instead of its own URL (https://…).

ERPnext is behind a reverse proxy. I read in a different forum, that the same problem also occured with grafana being behind a reverse proxy and there the solution was to add the following to the environmental variables: GF_SERVER_ROOT_URL: “https://grafana.domain.com

It seems to me, that I have the same problem, and I’m stuck of how I could manage to make erpnext transmit the site-url instead of the local IP-address.

Does anybody have an idea of how I could achieve this?
Thanks a lot for any idea.