(我可能需要 keycloak pro 来实现这一点。不确定。)

  • 我在我的 Fedora 机器上运行着 keycloak 作为服务。

  • 它正在监听管理控制台的端口 5006/5007 – 5007。

  • 管理控制台只能从地址 10.9.8.0/24 和 127.0.0.1 访问

  • 我的 nginx 代理‘后面’的任何通信都应该是 http。

+----------------------+
| (Angular)app/browser |
+----------------------+
           |
         https
           |
   +------------------+
   |    example.com   |
   |      NGINX       |
   |    10.9.8.1      |<------ http -----+
   +------------------+                  |
                                         |
   +---------------+                     |
   |   Keycloak    |<-- authentication --+
   +---------------+                     |
           ^                             |
           |                             |
     authorisation                       |
           |                             |
           +------------- Requests ------+---------------+
           |                 |                           |
           v                 v                           v
   +----------------+  +--------------------+  +--------------------+
   |   C# SignalR   |  |  C# web services   |  |      Angular       |
   +----------------+  +--------------------+  +--------------------+

我的 nginx 配置如下:

# Proxy for the authentication server (public)
location /auth/ {
    proxy_pass http://127.0.0.1:5006/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 for the admin interface
location /admin/ {
    allow 10.9.8.0/24;
    allow 127.0.0.1;
    deny all;

    proxy_pass http://127.0.0.1:5007/;
    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_buffering off;   # Ensure real-time responses from Keycloak
}

keyCloak 是这样的

feature=hostname:v1

# Configuration for the authentication server (public)
http-enabled=true
http-host=127.0.0.1
http-port=5006

# Configuration for the admin interface
http-management-port=5007

# Hostname settings
hostname=example.com
hostname-url=https://example.com/auth
hostname-admin-url=https://example.com/admin

当我浏览(从我的 10.9.8.0/24 网络上的节点)时,我看到的只是一个白页,上面写着“Keycloak 管理界面”文字。tail -f /var/log/nginx/error.log没有显示错误,并且 chrome 中的网络跟踪显示单个 200 响应。

另一方面,We are sorry... Page not found显示一个带有 keycloak 徽标和消息的页面,并且网络跟踪中出现 404 错误。

我失去了一些东西,但我不知道它是什么。

0