gpt4 book ai didi

docker - 访问 Wildfly 管理控制台时出错 - 需要身份验证

转载 作者:行者123 更新时间:2023-12-04 17:45:14 27 4
gpt4 key购买 nike

我在登录 Wildfly 13 管理控制台 后收到错误消息需要身份验证

如果我输入错误的用户名或密码,它会再次询问,但如果我输入正确,它会显示带有错误消息的页面(所以我假设用户名和密码是正确的,但之后的其他内容会给出错误)。

enter image description here

我正在使用 docker 来运行一个 nginx 容器和一个 wildfly 容器。

nginx 在端口 9991 上进行外部监听,代理将请求传递给 wildfly 容器,但它显示之前描述的错误。

它只发生在 Wildfly 控制台,所有其他请求都被代理,甚至请求被代理到 websocket 或端口 8080 上的 Wildfly,都成功完成.

Wildfly 容器在端口 9990 上进行外部监听,我可以在此端口成功访问控制台。如果在 docker 上,我映射端口 "9992:9990" 我仍然可以通过端口 9992 成功访问控制台

所以,这似乎与docker无关,而是与Wildfly Console本身有关。可能在中间使用反向代理时无法成功进行某种身份验证。

我在 https://github.com/lucasbasquerotto/pod/tree/0.0.6 上有一个演示 docker 项目,您可以下载标签 0.0.6,该标签的所有设置都可以与 Wildfly 13 和 nginx 一起使用,并模拟此错误。

git clone -b 0.0.6 --single-branch --depth 1 https://github.com/lucasbasquerotto/pod.git
cd pod
docker-compose up -d

然后,如果您使用用户 monitor 和密码 Monitor#70365 直接在 http://localhost:9990 中访问容器 一切正常

但如果您使用相同的凭据访问 http://localhost:9991通过 nginx 反向代理,您会收到错误

我的 nginx.conf 文件:

upstream docker-wildfly {
server wildfly:9990;
}

location / {
proxy_pass http://docker-wildfly;
proxy_redirect off;
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 $server_name;
}

我也尝试过:

proxy_set_header   X-Forwarded-Proto $scheme;

还有 Authorization header(只是第二行,也有两行):

proxy_set_header   Authorization $http_authorization;
proxy_pass_header Authorization;

并且还定义了带有端口的主机 header (而不仅仅是$host):

proxy_set_header   Host $server_addr:$server_port;

我已经尝试将上述配置分开并组合在一起。一切都无济于事。

有什么建议吗?

有没有人通过反向代理成功访问过Wildfly控制台?

更新 (2018-09-22)

Wildfly 似乎使用了摘要式身份验证(而不是基本身份验证)。

我在控制台中看到标题如下:

Authorization: Digest username="monitor", realm="ManagementRealm", nonce="AAAAAQAAAStPzpEGR3LxjJcd+HqIX2eJ+W8JuzRHejXPcGH++43AGWSVYTA=", uri="/console/index.html", algorithm=MD5, response="8d5b2b26adce452555d13598e77c0f63", opaque="00000000000000000000000000000000", qop=auth, nc=00000005, cnonce="fe0e31dd57f83948"

我没有看到太多关于使用 nginx 来代理带有摘要 header 的传递请求的文档(但我认为它应该是透明的)。

我在 SO 中看到的一个问题是 https://serverfault.com/questions/750213/http-digest-authentication-on-proxied-server , 但目前还没有答案。

看到有nginx非官方模块https://www.nginx.com/resources/wiki/modules/auth_digest/ ,但在 github 存储库 ( https://github.com/atomx/nginx-http-auth-digest ) 中它说:

The ngx_http_auth_digest module supplements Nginx's built-in BasicAuthentication module by providing support for RFC 2617 DigestAuthentication. The module is currently functional but has only beentested and reviewed by its author. And given that this is securitycode, one set of eyes is almost certainly insufficient to guaranteethat it's 100% correct. Until a few bug reports come in and some ofthe ‘unknown unknowns’ in the code are flushed out, consider thismodule an ‘alpha’ and treat it with the appropriate amount ofskepticism.

在我看来,硬编码用户并传入一个文件以供 nginx 使用(在这种情况下,身份验证应该对反向代理透明)。

无论如何,我都试过了,它正确地要求我进行身份验证,即使最终目的地没有摘要式身份验证,比如在尝试连接到 wildfly 站点(不是控制台)时,它会在尝试连接时询问到 nginx(在代理请求之前),然后它成功转发到目的地,除了在 wildfly 控制台的情况下,它一直要求我永远进行身份验证。

所以我认为这不是解决方案。问题似乎在于 nginx 传递给 Wildfly 控制台的内容。

最佳答案

我在 HAL 管理控制台 v3.3 和 3.2 上遇到了同样的问题由于身份验证错误,我无法让 ngnix HTTPS 工作,即使页面提示 http basic auth user and pass

这是在同一台服务器上以独立模式测试的

我的设置是:外部 (https) -> nginx -> http://halServer:9990/这导致 https 正常工作,但出现 HAL 身份验证错误(在浏览器控制台中看到),网页为空白。一开始访问网页会正常询问http basic auth凭据,但后来几乎所有的https请求都会返回一个认证错误

我首先使用自签名证书启用 HAL 控制台 https,然后配置 nginx 以代理传递给 HAL HTTPS 监听器,从而使其正常工作

工作设置是:外部 (https) -> nginx (https) -> https://halServer:9993/

这是ngnix配置

server {
listen 80;
listen [::]:80;
listen 443 ssl;
listen [::]:443 ssl;
server_name halconsole.mywebsite.com;

# SSL
ssl_certificate /keys/hal_fullchain.pem;
ssl_certificate_key /keys/hal_privkey.pem;
ssl_trusted_certificate /keys/hal_chain.pem;

# security
include nginxconfig.io/security.conf;

# logging
access_log /var/log/nginx/halconsole.mywebsite.com.access.log;
error_log /var/log/nginx/halconsole.mywebsite.com.error.log warn;

# reverse proxy
location / {
# or use static ip, or nginx upstream
proxy_pass https://halServer:9993;
include nginxconfig.io/proxy.conf;
}

# additional config
include nginxconfig.io/general.conf;
include nginxconfig.io/letsencrypt.conf;
}

# subdomains redirect
server {
listen 443 ssl;
listen [::]:443 ssl;
server_name *.halconsole.mywebsite.com;

# SSL
ssl_certificate /keys/hal_fullchain.pem;
ssl_certificate_key /keys/hal_privkey.pem;
ssl_trusted_certificate /keys/hal_chain.pem;
return 301 https://halconsole.mywebsite.com$request_uri;
}

代理配置文件

proxy_http_version                 1.1;
proxy_cache_bypass $http_upgrade;

# Proxy headers
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Forwarded $proxy_add_forwarded;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Port $server_port;
proxy_set_header X-Forwarded-By $server_addr;

# Proxy timeouts
proxy_connect_timeout 60s;
proxy_send_timeout 60s;
proxy_read_timeout 60s;

启用 https 控制台的最简单方法是使用控制台本身

  1. 使用命令行 keytool 或 GUI 程序生成 java JKS keystore 我喜欢 GUI,所以我使用了 Key Store Explorer https://github.com/kaikramer/keystore-explorer

  2. 将 keystore 文件复制到具有读取权限的 halServer 服务器上(无需保密)我将我的 keystore 文件放在“ keystore ”目录中的 wildfly 数据目录中。

# your file paths might differ, don't copy paste
cp /home/someUser/sftp_uploads/managementKS /opt/wildfly/standalone/data/keystore/managementKS
  1. 设置权限
# your file paths might differ, don't copy paste
chown --recursive -H wildfly:wildfly /opt/wildfly/standalone/data/keystore
  1. (使用vpn)登录明文控制台http://halServer:9990/

  2. 添加 keystore :导航:

     configuration -> subsystems -> security (elytron) -> other settings (click view button)
    stores -> keystore -> add
    ...
    Name = managementKS
    Type = JKS
    Path = keystore/managementKS
    Relative to = jboss.server.data.dir
    Credential Reference Clear Text = keystore-password click Add

结果为 standalone.xml

<key-store name="managementKS">
<credential-reference clear-text="keystore-password"/>
<implementation type="JKS"/>
<file path="keystore/managementKS" relative-to="jboss.server.data.dir"/>
</key-store>
  1. 添加 key 管理器:导航:

     ssl -> key manager -> add
    ...
    Name = managementKM
    Credential Reference Clear Text = keystore-password
    Key Store = managementKS

结果为 standalone.xml

<key-manager name="managementKM" key-store="managementKS">
<credential-reference clear-text="keystore-password"/>
</key-manager>
  1. 添加 ssl 上下文:导航:

     ssl -> server ssl context -> add
    ...
    Name = managementSSC
    Key Manager = managementKM
    ...
    Edit added : Protocols = TLSv1.2
    save

结果为 standalone.xml

<server-ssl-contexts>
<server-ssl-context name="managementSSC" protocols="TLSv1.2" key-manager="managementKM"/>
</server-ssl-contexts>
  1. 返回

     runtime -> server (click view button)
    http management interface (edit)
    set secure socket binding = management-https
    set ssl context = managementSSC
    save
  2. 重启野蝇

     systemctl restart wildfly

关于docker - 访问 Wildfly 管理控制台时出错 - 需要身份验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52452474/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com