nginx - Wildfly 16 在 NGINX 后面带有 http-remoting:JBREM000202
问题描述
我试图将 Wildfly 16 作为反向代理放在 NGINX 后面。我想使用 http-remoting 为 EJB 提供服务。
这是我的 NGINX 配置:
server {
listen 81;
server_name 10.0.2.15;
location / {
set $should_proxy "";
set $upgrade_header "";
if ($http_sec_jbossremoting_key) {
set $should_proxy "Y";
}
if ($should_proxy = Y) {
proxy_pass http://127.0.0.1:8080;
set $upgrade_header "upgrade";
}
proxy_set_header Sec-JbossRemoting-Key $http_sec_jbossremoting_key;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Host $http_host;
proxy_set_header Connection $upgrade_header;
}
}
但是,在我得到的 EJB 客户端上
IOException: JBREM000202: Abrupt close on Remoting connection
我尝试获取 NGINX 生成的标头,并使用 tcpdump 和以下输出:
00:16:08.083162 IP (tos 0x0, ttl 64, id 34533, offset 0, flags [DF], proto TCP (6), length 185)
localhost.34890 > localhost.http-alt: Flags [P.], cksum 0xfead (incorrect -> 0x81b5), seq 1:134, ack 1, win 512, options [nop,nop,TS val 1104278851 ecr 1104278851], length 133: HTTP, length: 133
GET / HTTP/1.0
Sec-JbossRemoting-Key: iy2PuEO5anDKgm4w2+o0Tw==
Upgrade: jboss-remoting
Host: 10.0.2.15:81
Connection: upgrade
00:16:08.083165 IP (tos 0x0, ttl 64, id 42808, offset 0, flags [DF], proto TCP (6), length 52)
localhost.http-alt > localhost.34890: Flags [.], cksum 0xfe28 (incorrect -> 0x753d), ack 134, win 511, options [nop,nop,TS val 1104278851 ecr 1104278851], length 0
00:16:08.083690 IP (tos 0x0, ttl 64, id 42809, offset 0, flags [DF], proto TCP (6), length 227)
localhost.http-alt > localhost.34890: Flags [P.], cksum 0xfed7 (incorrect -> 0x1ada), seq 1:176, ack 134, win 512, options [nop,nop,TS val 1104278852 ecr 1104278851], length 175: HTTP, length: 175
HTTP/1.1 101 Switching Protocols
Connection: Upgrade
Upgrade: jboss-remoting
Sec-JbossRemoting-Accept: ofI3qxa1miPoq1vhp3tDCO5r/kw=
Date: Sat, 20 Jun 2020 22:16:08 GMT
与直接发送到 Wildfly 的请求相比,它们看起来相同。我不知道如何进一步调试。
有什么想法我可能做错了吗?
解决方案
这是我的 nginx 配置的样子,它可以工作:
location / {
proxy_pass http://127.0.0.6:9990;
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 Host $http_host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Frame-Options SAMEORIGIN;
#for proxying wildfly
proxy_set_header sec_jbossremoting_key $http_sec_jbossremoting_key;
proxy_set_header sec_hornetqremoting_key $http_sec_hornetqremoting_key;
proxy_set_header upgrade $http_upgrade;
proxy_set_header connection "upgrade";
proxy_set_header host $http_host;
}
您可以通过执行jboss-cli.sh脚本进行调试,看看是否可以连接。
首先,尝试直接向wildfly发送请求,在我的例子中是127.0.0.6:9990
[user@server]# /opt/wildfly/bin/jboss-cli.sh --controller=127.0.0.6:9990 --connect
[standalone@127.0.0.6:9990 /] version
JBoss Admin Command-line Interface
然后,尝试通过 nginx 连接,在我的情况下是 172.16.20.11:9990
[user@server]# /opt/wildfly-8.2.1.Final/bin/jboss-cli.sh --controller=172.16.20.11:9990 --connect
[standalone@172.16.20.11:9990 /] version
运行脚本会告诉你你有什么样的错误,而不是 nginx :)
推荐阅读
- javascript - VS Code 在使用 Live Server 时显示目录结构而不是 app.js 文件
- ruby - 在冰糕中,你能指定一个类型是一个类的后代吗?
- python - 如何将日志文件转换为 pandas DF
- linux - 内核模块重新加载后中断处理程序停止工作(Xilinx FPGA / PCIe)
- java - 哪个 java 类在 catalina.out 上发出警告
- java - 在反向代理后面访问 ElasticDB
- java - 避免对未获取的惰性对象进行 GSON 序列化
- python - 使用深度 CNN 和完全连接的分类器转换分割掩码 numpy 数组以进行图像分割
- google-apps-script - 谷歌表格 - 通过匹配值搜索/替换
- mysql - 使具有多个存在条件的 if 语句在 true 时插入