Seeking guidance on OpenMRS Container Startup Failure on enabling oauth2login module

Hi all ,

While running OpenMRS 2.6.x (using Bahmni image) on Kubernetes with the oauth2login module and Keycloak. Locally via Docker Compose, everything works perfectly using plain HTTP. However, in our Kubernetes cluster, the OpenMRS container immediately exits at startup. The issue occurs because our OAuth2 browser URL uses HTTPS with a certificate issued by an internal CA.

Local Environment (Works) No TLS involved. Both sides use HTTP:

OAUTH2_INTERNAL_URL=http://keycloak:8080

OAUTH2_BROWSER_URL=http://localhoost

Kubernetes Environment (Fails) Browsers must reach Keycloak at the public HTTPS host, so OAUTH2_BROWSER_URLmust use the external domain:

OAUTH2_BROWSER_URL=https://auth.example.com

OAUTH2_BASE_URL=http://keycloak-internal-service:8080

failure path :

  • The image’s startup.sh script runs .
  • It starts Tomcat in the background and then runs a warm-up check: curl -sL ``http://localhost:8080/openmrs/.
  • Because OAuth2 is enabled, /openmrs/ immediately redirects to [``https://auth.example.com/``](``https://auth.example.com/``)....
  • curl to follow sthe redirect to the HTTPS external URL.
  • And fails because it doesn’t trust the internal CA .
  • the curl failure ( exit 7 ) aborts the entire script, causing the container to exit.

What is the actual purpose of this curl warm-up check during container initialization? Is it strictly necessary for OpenMRS startup, and what would be the potential impact of bypassing or modifying this check?

Is there a built-in environment variable or configuration to bypass this specific curl warm-up check in the OpenMRS startup script? Alternatively, if the check cannot be bypassed, is the recommended approach to mount our internal CA certificate into /etc/pki/tls/certs/ inside the container before the script runs, or is there a cleaner way to handle OAuth2 redirects during container initialization?

Thanks! @ibacher @mseaton @mksd @angshuonline

We have have investigated a little more onto this. As mentioned above, the startup.sh script is triggering the application base URL during startup. The below block is the one which triggers.

# Trigger first filter to start data import
sleep 15
curl -sL "http://localhost:8080/${OMRS_WEBAPP_NAME}/" > /dev/null || true
sleep 15

# Bring tomcat process to foreground again
wait ${!}

Since the curl command here follows re-directs also, it reaches till the Oauth Module redirects to the configured User Authorisation URL.

In many infrastructure teams, we have faced problems wherein, the internal networks cannot reach the public DNS of the same server. This is usually blocked as NAT Hairpin issues or Loopback issues.

We also see that this curl has been removed on the master branch. Can someone please help us understand why this is needed ? Also if this is optional, can we have a patch on OMRS 2.8 to remove the CURL.

@mksd @dkayiwa @mseaton @raff @burke @ibacher @mksrom

It’s non-optional or, more exactly, the first web request is what actually triggers OpenMRS to start. master appears to have switched to depending on the health-check and that looks more like an oversight than a recommended setup. With newer versions of OpenMRS we could conceivably hit the /health endpoint (assuming oauth2login ignores it; I’m guessing it doesn’t), but that wouldn’t work for OMRS 2.6 which doesn’t have a defined response for those.

1 Like