Working setup
I have a configuration of
- external VPS with public IP that has Nginx reverse proxy (A)
- internal server with Nginx (B)
- standalone application (not containerized) Keycloak 17.0.1
Which looks like this. I had a domain registrered for that server which is (let's say) auth.example.com
When I go to https://auth.example.com I can see regular keycloak page with link to admin console.
By clicking on the administration console I can properly login to manage master realm.
The problem
As soon as I containerize keycloak all links for administration console and some scripts are no longer working as they are changed from https://auth.example.com
to https://localhost
Configs
By containerizing keycloak I did not modify any of the nginx configs.
Nginx A
location /
{
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-Port $server_port;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://[nginx b ip];
}
Nginx B
server
{
server_name auth.example.com;
location /
{
proxy_pass http://localhost:[exposed docker port];
}
listen 80;
}
Standalone keycloak (working command)
/usr/bin/bash bin/kc.sh start --proxy edge --hostname=auth.example.com --db-url-host localhost --db-username keycloak --db-password password
Dockerized keycloak (docker-compose)
keycloak:
image: quay.io/keycloak/keycloak:latest
command: start --auto-build --features=token-exchange --hostname-strict-backchannel=true --hostname=auth.example.com
depends_on:
- db
environment:
KC_METRICS_ENABLED: "true"
DB_VENDOR: [somedbvendor]
DB_ADDR: db
DB_DATABASE: keycloak
DB_USER: keycloak
DB_PASSWORD: password
KEYCLOAK_ADMIN: admin
KEYCLOAK_ADMIN_PASSWORD: admin
KC_PROXY: edge
PROXY_ADDRESS_FORWARDING: "true"
ports:
- "8081:8080"
networks:
- net
I would like to containerize whole application I have and their dependencies and keycloak is a first step that I cannot complete.