Keycloak Setup Errors & Resolutions
β Correct Startup Command for Keycloak 26.x
Use only the --proxy-headers
flag, and enable HTTP since NGINX handles TLS:
bash
nohup ./kc.sh start \
--http-enabled=true \
--http-host=192.168.0.25 \
--proxy-headers=xforwarded \
--hostname-strict=false \
> output.log 2>&1 &
Explanation:
--proxy-headers=xforwarded
: Tells Keycloak to trust theX-Forwarded-*
headers from NGINX--http-enabled=true
: Required when TLS is terminated by a proxy--hostname-strict=false
: Allows Keycloak to accept the hostname provided by the proxy
β Do not use --proxy=edge
βKeycloak 26 now uses the proxy-headers
system exclusively
1. Unable to Kill Keycloak Started with nohup
π Problem
You tried:
bash
kill $(cat keycloak.pid)
kill -9 $(cat keycloak.pid)
But received:
arduino
No such process
Even repeated nohup ./kc.sh start ...
led to unexpected behavior and exit code 2.
π Root Causes
The PID file may not match the actual Java process running Keycloak, only the wrapper script
kc.sh
.nohup
detaches the process; after wrapper exits, the real process continues under a new PID.
β Solution
bash
# 1. Find the Java process
ps -ef | grep '[q]uarkus.bootstrap.runner.QuarkusEntryPoint'
# 2. Kill it gracefully
kill <PID>
# 3. If that fails, force kill
kill -9 <PID>
# 4. Confirm termination
pgrep -f 'QuarkusEntryPoint' || echo "Stopped"
# 5. Clean up stale files
rm -f keycloak.pid output.log nohup.out
Tip: When starting Keycloak, capture the actual Java PID:
bash
nohup ./kc.sh start β¦ & sleep 3
pgrep -f 'QuarkusEntryPoint' > keycloak.pid
This ensures you're always targeting the correct process.
2. β NGINX Reverse Proxy Missing Critical Headers
π Problem
Your existing NGINX config lacks headers needed by Keycloak:
nginx
proxy_set_header X-Real-IP β¦;
proxy_set_header X-Forwarded-For β¦;
proxy_set_header X-Forwarded-Proto β¦;
Missing headers can cause:
Mixedβcontent (HTTP assets on HTTPS page)
"Invalid redirect_uri" errors
Blank or broken admin console
β Corrected NGINX SSL Block
nginx
{
proxy_pass http://192.168.0.25:8080;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Port $server_port;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
Why this is needed:
X-Forwarded-Proto
& others ensure Keycloak sees the true https:// URL and correct host/port, fixing asset loading and redirect issues.Client IP logging/auditing requires
X-Real-IP
andX-Forwarded-For
.