On 03/02/2017 12:50 PM, Eric Covener wrote:
> Curious about the headers in the bug report / recreate.
I have looked to the problem again I have 2 JIRA related to the commit:
https://issues.jboss.org/browse/JBCS-254
https://issues.jboss.org/browse/JBCS-291
Basically people using mod_proxy_wstunnel with jboss-remoting and
HTTP/1.1 + upgrade WebSocket.
For the jboss-remoting: (httpd to server)
GET / HTTP/1.1
Host: localhost:8080
Sec-JbossRemoting-Key: NGELpfuU01no5ZPM9705Fg==
X-Forwarded-For: 127.0.0.1
X-Forwarded-Host: localhost:8282
X-Forwarded-Server: fe80::56ee:75ff:fe1d:45fb
Upgrade: jboss-remoting
Connection: Upgrade
HTTP/1.1 101 Switching Protocols
Connection: Upgrade
Upgrade: jboss-remoting
Sec-JbossRemoting-Accept: QR2l+ma75tZ4T1yrrJ/wxNwDPwg=
Date: Wed, 19 Apr 2017 08:01:18 GMT
client to proxy:
GET / HTTP/1.1
Sec-JbossRemoting-Key: NGELpfuU01no5ZPM9705Fg==
Upgrade: jboss-remoting
Host: localhost:8282
Connection: upgrade
HTTP/1.1 101 Switching Protocols
Connection: Upgrade
Upgrade: jboss-remoting
Sec-JbossRemoting-Accept: QR2l+ma75tZ4T1yrrJ/wxNwDPwg=
Date: Wed, 19 Apr 2017 08:01:18 GMT
.......
The HTTP/1.1 + upgrade: (basically it get the websocket app using
HTTP/1.1 and then)
GET /jboss-websocket-hello/websocket/helloName HTTP/1.1
Host: localhost:8000
User-Agent: Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:52.0)
Gecko/20100101 Firefox/52.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.7,ca;q=0.3
Accept-Encoding: gzip, deflate
Sec-WebSocket-Version: 13
Origin: http://localhost:8000
Sec-WebSocket-Extensions: permessage-deflate
Sec-WebSocket-Key: IPPsC2JbqOS1QfWepOVnvQ==
Connection: keep-alive, Upgrade
Pragma: no-cache
Cache-Control: no-cache
Upgrade: websocket
HTTP/1.1 101
Upgrade: websocket
Connection: upgrade
Sec-WebSocket-Accept: PVBn1cxiXtjKaAeECRlpKv6lOaA=
Sec-WebSocket-Extensions: permessage-deflate
Date: Wed, 19 Apr 2017 08:17:36 GMT
So I need 2 things:
1 - Upgrade to jboss-remoting.
2 - Proxy without the upgrade header.
To try something I have used:
flusher=jboss-remoting (basically does the tunnel for another protocol)
flusher=NONE (basically bypass the checks added by r1674661).
I don't think mod_proxy_fdpass will be used with mod_proxy_wstunnel and
flusher looks like scheme for the size.
Any better suggestion before I commit the patch?
Cheers
Jean-Frederic
>
> On Thu, Mar 2, 2017 at 6:31 AM, Jim Jagielski <[email protected]> wrote:
>>
>>> On Mar 2, 2017, at 5:58 AM, jean-frederic clere <[email protected]> wrote:
>>>
>>>>
>>>> + upgrade = apr_table_get(r->headers_in, "Upgrade");
>>>> + if (!upgrade || strcasecmp(upgrade, "WebSocket") != 0) {
>>>> + ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(02900)
>>>> + "declining URL %s (not WebSocket)", url);
>>>> + return DECLINED;
>>>
>>> In fact this causing regression for some customer, could we make that
>>> switch able? See https://issues.jboss.org/browse/JBCS-291
>>>
>>
>> Sure!
>>
>
>
>
Index: modules/proxy/mod_proxy_wstunnel.c
===================================================================
--- modules/proxy/mod_proxy_wstunnel.c (revision 1783641)
+++ modules/proxy/mod_proxy_wstunnel.c (working copy)
@@ -313,6 +313,7 @@
ws_baton_t *baton = apr_pcalloc(r->pool, sizeof(ws_baton_t));
int status;
proxyws_dir_conf *dconf = ap_get_module_config(r->per_dir_config,
&proxy_wstunnel_module);
+ const char *upgrade_method = *worker->s->flusher ? worker->s->flusher :
"WebSocket";
header_brigade = apr_brigade_create(p, backconn->bucket_alloc);
@@ -325,7 +326,11 @@
return rv;
}
- buf = apr_pstrdup(p, "Upgrade: WebSocket" CRLF "Connection: Upgrade" CRLF
CRLF);
+ if (ap_cstr_casecmp(upgrade_method, "NONE") == 0) {
+ buf = apr_pstrdup(p, "Upgrade: WebSocket" CRLF "Connection: Upgrade"
CRLF CRLF);
+ } else {
+ buf = apr_pstrcat(p, "Upgrade: ", upgrade_method, CRLF "Connection:
Upgrade" CRLF CRLF, NULL);
+ }
ap_xlate_proto_to_ascii(buf, strlen(buf));
e = apr_bucket_pool_create(buf, strlen(buf), p, c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(header_brigade, e);
@@ -445,12 +450,12 @@
int status;
char server_portstr[32];
proxy_conn_rec *backend = NULL;
- const char *upgrade;
char *scheme;
apr_pool_t *p = r->pool;
char *locurl = url;
apr_uri_t *uri;
int is_ssl = 0;
+ const char *upgrade_method = *worker->s->flusher ? worker->s->flusher :
"WebSocket";
if (ap_cstr_casecmpn(url, "wss:", 4) == 0) {
scheme = "WSS";
@@ -464,12 +469,15 @@
return DECLINED;
}
- upgrade = apr_table_get(r->headers_in, "Upgrade");
- if (!upgrade || ap_cstr_casecmp(upgrade, "WebSocket") != 0) {
- ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(02900)
- "declining URL %s (not WebSocket, Upgrade: header is
%s)",
- url, upgrade ? upgrade : "missing");
- return DECLINED;
+ if (ap_cstr_casecmp(upgrade_method, "NONE") != 0) {
+ const char *upgrade;
+ upgrade = apr_table_get(r->headers_in, "Upgrade");
+ if (!upgrade || ap_cstr_casecmp(upgrade, upgrade_method) != 0) {
+ ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(02900)
+ "declining URL %s (not %s, Upgrade: header is %s)",
+ url, upgrade_method, upgrade ? upgrade : "missing");
+ return DECLINED;
+ }
}
uri = apr_palloc(p, sizeof(*uri));