0

我正在尝试使用 Apache 2 创建一个 SSL 代理,该代理在端口 443 上侦听并根据上下文在不同的 IP/端口上转发请求:

设想:

发出 jBoss“https-remoting”请求(它使用 HTTP1.1 在 Wildfly 8.2 中升级为“jboss-remoting”),来自:

https://xxxxxxx.com:443

并将其转发至:

http://192.168.x.y:8080

我发现以下 RewriteCond 有效:

RewriteCond %{HTTP:Upgrade} jboss-remoting [NC]
RewriteRule ^/(.*)$ http://192.168.x.y:8080/$1 [P]

但我不知道我应该应用什么 RewriteRule 才能请求继续进行 http-remoting 而不是 http。

阿帕奇输入:

GET / HTTP/1.1\r\n
Sec-JbossRemoting-Key: WJaD+AcnutfrXiBna+KL5w==\r\n
Upgrade: jboss-remoting\r\n
Host: xxxxxxx.com\r\n
Connection: upgrade\r\n

阿帕奇输出:

GET / HTTP/1.1\r\n
Host: xxxxxxx.com\r\n
Sec-JbossRemoting-Key: WJaD+AcnutfrXiBna+KL5w==\r\n
X-Forwarded-For: 192.168.x.y\r\n
X-Forwarded-Host: xxxxxxx.com\r\n
X-Forwarded-Server: xxxxxxx.com\r\n
Connection: Keep-Alive\r\n

如您所见,Upgrade 和 Connection 标头已被删除。有没有办法可以转发所有内容?

4

1 回答 1

0

找到了解决方案。它包括从 Apache 2.4+ 破解 mod_proxy_wstunnel 以支持 jboss-remoting 升级。

作为快速破解,您需要编辑以下文件:

mod_proxy_wstunnel.c

强制更改:

升级标头需要从以下位置修补:

buf = apr_pstrdup(p, "Upgrade: WebSocket" CRLF "Connection: Upgrade" CRLF CRLF);

buf = apr_pstrdup(p, "Upgrade: jboss-remoting" CRLF "Connection: Upgrade" CRLF CRLF);

和以下行:

 if (!upgrade || strcasecmp(upgrade, "WebSocket") != 0)

if (!upgrade || strcasecmp(upgrade, "jboss-remoting") != 0)

现在,一个简单的重写规则就可以了:

RewriteRule ^/(.*)$ ws://IP2:8080 [P]

注意“ws”协议。它需要它来触发升级。

代码是这样工作的,但是您也应该修补协议/mod_proxy_wstunnel 文件并使所有内容更加通用。

于 2015-10-16T13:55:18.517 回答