WildFly console served with nginx

uubf1zoe  于 2023-04-20  发布在  Nginx
关注(0)|答案(3)|浏览(129)

我坚持在AWS上配置一个简单的反向代理。由于我们有一个主机(反向代理nginx)服务于公共访问,我决定遵循规则并创建以下配置。

server {
    listen      9990;
    server_name project-wildfly.domain.me;

    access_log  /var/log/nginx/wildfly.access.log;
    error_log   /var/log/nginx/wildfly.error.log;

    proxy_buffers 16 64k;
    proxy_buffer_size 128k;

    root   /var/www/;
    index  index.html index.htm;

    location /console {
        proxy_set_header Host $server_addr:$server_port;
        proxy_set_header X-Forwarded-Proto $scheme;

        add_header Cache-Control "no-cache, no-store";
        proxy_pass http://10.124.1.120:9990/console;
    }

    location /management {
        proxy_set_header Host $server_addr:$server_port;
        proxy_set_header X-Forwarded-Proto $scheme;

        add_header Cache-Control "no-cache, no-store";
        proxy_pass http://10.124.1.120:9990/management;
    }
}

这将服务于管理控制台,我可以使用该用户登录。然后出现以下消息:
拒绝访问
权限不足,无法访问此接口。
错误日志中没有任何内容。感谢您的任何提示!

xpcnnkqh

xpcnnkqh1#

我在配置Wildfly 15和nginx 1.10.3作为反向代理时遇到了同样的问题。安装程序与第一篇文章非常相似,将/management & /console重定向到wildflyhost:9990。
我可以通过:9990直接访问控制台,当比较直接和nginx代理流量之间的网络流量时,我注意到Origin和Host是不同的。
因此,在我的情况下,解决方案是强制Nginx中的Origin和Host标头为Wildfly所期望的东西。我在其他地方找不到这个解决方案,所以我在这里发布它以供将来参考,尽管线程很旧。

location /.../ {
    proxy_set_header Host $host:9990;
    proxy_set_header Origin http://$host:9990;

    proxy_redirect off;
    proxy_http_version 1.1;
    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_pass_request_headers on;
    proxy_pass http://wildflyhost:9990
...
}
insrf1ej

insrf1ej2#

谢谢大家,我通过nginx访问wildfly 27的解决方案是:
关于standalone.xml

<interface name="management">
    <any-address/>
</interface>
<interface name="public">
    <any-address/>
</interface>

在nginx.conf上,我创建了两个位置:

location /console {
    proxy_set_header Host *wildflyserver*:9990;
    proxy_set_header Origin http://*wildflyserver*:9990;
    proxy_pass http://*wildflyserver*:9990/console;
}

location /management {
    proxy_set_header Host *wildflyserver*:9990;
    proxy_set_header Origin http://*wildflyserver*:9990;
    proxy_pass http://*wildflyserver*:9990/management;
}
e0bqpujr

e0bqpujr3#

也许你需要打开management模块。
标签:sh standalone.sh -b 0.0.0.0 -bmanagement 0.0.0.0 &

相关问题