Skip to content

Instantly share code, notes, and snippets.

@vincentchalamon
Last active June 5, 2024 14:46
Show Gist options
  • Save vincentchalamon/81ab81fbe19d36d4ea75d78c6a5388c3 to your computer and use it in GitHub Desktop.
Save vincentchalamon/81ab81fbe19d36d4ea75d78c6a5388c3 to your computer and use it in GitHub Desktop.
# ...
# Matches requests for OIDC routes
@oidc expression path('/oidc/*')
route {
# ...
reverse_proxy @oidc http://{$OIDC_UPSTREAM}
}
version: "3.8"
services:
# ...
php:
# ...
environment:
# ...
OIDC_UPSTREAM: keycloak:8080
keycloak:
image: bitnami/keycloak:21-debian-11
environment:
# ...
# Must finish with a trailing slash (https://github.com/bitnami/charts/issues/10885#issuecomment-1414279144)
KEYCLOAK_HTTP_RELATIVE_PATH: /oidc/
# https://www.keycloak.org/server/hostname
KC_HOSTNAME_URL: https://${SERVER_NAME:-localhost}/oidc/
@Selanas
Copy link

Selanas commented May 31, 2024

Bonjour,

Je vous contact car suite a votre conférence, et dans l'idée de suivre le même titre l'implémentation en reverse proxy, je me demandais a quoi correspondait la variable d'environnement {$OIDC_UPSTREAM} car je ne trouve rien de similaire dans les docs.

Merci !

@vincentchalamon
Copy link
Author

vincentchalamon commented May 31, 2024

Bonjour @Selanas,

Dans le fichier Caddyfile, la syntaxe {$OIDC_UPSTREAM} fait référence à une variable d'environnement custom attendue dans le système. Il faut donc penser à la déclarer au niveau du service correspondant :

# docker-compose.yaml
services:
  php:
    environment:
      # the "${...:-...}" syntax imports the environment variable from your system
      # and if it's not declared defines a default value (after ":-")
      OIDC_UPSTREAM: ${OIDC_UPSTREAM:-keycloak:8080}

Un exemple d'implémentation est disponible dans la Démo d'API Platform : https://github.com/api-platform/demo/blob/v3.3.5/compose.yaml

@Selanas
Copy link

Selanas commented Jun 5, 2024

Merci pour le retour !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment