首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何配置容器化Keycloak-gatekeeper作为反向代理?

如何配置容器化Keycloak-gatekeeper作为反向代理?
EN

Stack Overflow用户
提问于 2019-10-16 16:30:28
回答 1查看 1.8K关注 0票数 2

我想完成以下配置,以便为web服务器提供身份验证和授权:

每台服务器都是一个单独的Docker容器。特别地,我使用了下面的docker-compose.yml

代码语言:javascript
复制
version: '3'

volumes:
  mysql_data:
    driver: local

services:
  apache:
    image: bitnami/apache:2.4
  mysql:
      image: mysql:5.7
      volumes:
        - mysql_data:/var/lib/mysql
      environment:
        MYSQL_ROOT_PASSWORD: root
        MYSQL_DATABASE: keycloak
        MYSQL_USER: keycloak
        MYSQL_PASSWORD: password
  keycloak:
      image: jboss/keycloak
      environment:
        DB_VENDOR: MYSQL
        DB_ADDR: mysql
        DB_DATABASE: keycloak
        DB_USER: keycloak
        DB_PASSWORD: password
        KEYCLOAK_USER: admin
        KEYCLOAK_PASSWORD: Pa55w0rd
      ports:
        - 8080:8080
      depends_on:
        - mysql
  keycloak-gatekeeper:
    image: bitnami/keycloak-gatekeeper:2-scratch
    ports:
      - '3000:3000'
    volumes:
      - ./keycloak-gatekeeper.conf:/etc/keycloak-gatekeeper.conf
    command:
      - /keycloak-proxy
      - "--config=/etc/keycloak-gatekeeper.conf"

正如您所看到的,反向代理(Keycloak-gatekeeper)正在侦听端口3000,该端口也由Docker公开。我想要完成的是访问http://server_host:3000,用户被重定向到Keycloak进行身份验证,如果成功,则被重定向到正在侦听端口8080的web服务器。

这是我使用的keycloak-gatekeeper.conf

代码语言:javascript
复制
# is the url for retrieve the OpenID configuration - normally the <server>/auth/realm/<realm_name>
discovery-url: http://keycloak_keycloak_1:8080/auth/realms/master
# the client id for the 'client' application
client-id: gatekeeper
# the secret associated to the 'client' application
client-secret: 396af61a-b05b-417b-8153-0f827c0aab6e
# the interface definition you wish the proxy to listen, all interfaces is specified as ':<port>', unix sockets as unix://<REL_PATH>|</ABS PATH>
listen: 127.0.0.1:3000
# whether to enable refresh tokens
enable-refresh-tokens: false
# the redirection url, essentially the site url, note: /oauth/callback is added at the end
redirection-url: http://127.0.0.1:3000
# the upstream endpoint which we should proxy request
upstream-url: http://apache:8080/
secure-cookie: false
# a collection of resource i.e. urls that you wish to protect
# ======================================================================
resources:
- uri: /*
  methods:
  - GET

但是,在此配置下,访问http://server_host:3000的浏览器将显示一个ERR_CONNECTION_REFUSED。

可能的问题是什么?

EN

回答 1

Stack Overflow用户

发布于 2020-01-14 05:53:43

listen语句中使用127.0.0.1:3000时,我也遇到了同样的问题。请尝试使用:3000

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58408971

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档