I have two keycloak instances running on two separate swarm stacks.
this is how my stack file looks like:
INSTANCE 1
version: "3.4"
services:
# keycloak Server
keycloak:
image: jboss/keycloak:11.0.0
deploy:
replicas: 1
update_config:
parallelism: 1
delay: 10s
order: start-first
restart_policy:
condition: on-failure
environment:
# DB_STUFF
PROXY_ADDRESS_FORWARDING: "true"
ports:
- "18080:18080"
command:
- "-b"
- "0.0.0.0"
- "-Djboss.socket.binding.port-offset=10000"
INSTANCE 2
version: "3.4"
services:
# keycloak Server
keycloak:
image: jboss/keycloak:11.0.0
deploy:
replicas: 1
update_config:
parallelism: 1
delay: 10s
order: start-first
restart_policy:
condition: on-failure
environment:
# DB_STUFF
PROXY_ADDRESS_FORWARDING: "true"
ports:
- "18081:18081"
command:
- "-b"
- "0.0.0.0"
- "-Djboss.socket.binding.port-offset=10001"
And the nginx configuration:
location /auth/ {
proxy_pass http://localhost:18080/auth/;
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-Proto $scheme;
proxy_set_header X-Forwarded-Port 80;
}
location /auth2/ {
proxy_pass http://localhost:18081/auth/;
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-Proto $scheme;
proxy_set_header X-Forwarded-Port 80;
}
I wanted to be able to access each of them through a separate path, but when I try to access the admin console of the second instance at /auth2 it redirects me to the first one at /auth. I have little knowledge about nginx so any help is appreciated.