You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Yann Ylavic <yl...@gmail.com> on 2017/01/05 09:36:44 UTC

Re: [users@httpd] Web sockets & proxypass - No protocol handler was valid for the URL

On Wed, Dec 28, 2016 at 3:53 PM, Eric Covener <co...@gmail.com> wrote:
> On Tue, Dec 27, 2016 at 8:39 AM, Adam Teale <ad...@believe.tv> wrote:
>> Hi!
>>
>> I've been trying to setup a reverse proxy to a localhost websocket url.
>>
>> ProxyPass /chat/stream/ wss://localhost:8000/chat/stream/
>> ProxyPassReverse /chat/stream/ wss://localhost:8000/chat/stream/
>>
>> I get an error in the apache error_log that reads:
>>
>> No protocol handler was valid for the URL /chat/stream/. If you are using a
>> DSO version of mod_proxy, make sure the proxy submodules are included in the
>> configuration using LoadModule.
>>
>> I have read a lot of pages via google of people using this method so I
>> wonder if there is some issue in our setup/install of Apache that ships with
>> Mac OS X 10.11 & Server.app 5.2?
>>
>> I have all the standard modules loaded in httpd_server_app.conf
>>
>> LoadModule proxy_module libexec/apache2/mod_proxy.so
>> LoadModule proxy_http_module libexec/apache2/mod_proxy_http.so
>> LoadModule proxy_wstunnel_module libexec/apache2/mod_proxy_wstunnel.so
>>
>> When I access the application running on localhost:8000 directly on the
>> server everything works fine
>>
>> Any ideas what could be going on?
>
> There is a bug in this area, but you need to decide what you expect to
> happen with non-websockets requests to /chat/stream/ which is what's
> happening here.
>
> If you intend to proxy it, you might need to change the LoadModule
> order of mod_proxy_http and mod_proxy_wstunnel to try to get a
> different order at runtime.
>
> If you expect to satisfy it somehow else... you have a bit of a
> puzzler.  I'm not sure there's a good recipe for this.  Otherwise as
> Yann said, you should use different URLs if you can.

For the record (after private discussion with Adam), it seems that a
configuration like the below would work for http(s) and ws(s) on the
same URL:

  RewriteEngine on
  RewriteCond %{HTTP:Upgrade} "(?i)websocket"
  RewriteRule ^/(.*)$ wss://backend/$1 [P]
  ProxyPass / https://backend/

Actually it didn't work for him because of other app issues (Upgrade
missing), but httpd behaved correctly with this.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Web sockets & proxypass - No protocol handler was valid for the URL

Posted by Adam Teale <ad...@believe.tv>.
Hi Yann thanks again for all your help.

I am still trying to work out why the client isn't receiving the Upgrade
header in the response.
I see a proxy debug log:

[Thu Jan 05 11:04:24.002173 2017] [proxy:debug] [pid 65956]
proxy_util.c(3754): (54)Connection reset by peer: [client 127.0.0.1:51776]
AH03308: ap_proxy_transfer_between_connections: error on sock -
ap_get_brigade

[Thu Jan 05 11:04:24.002356 2017] [proxy:debug] [pid 65956]
proxy_util.c(2169): AH00943: WS: has released connection for (alfred.local)

[Thu Jan 05 11:04:28.001195 2017] [proxy:debug] [pid 65946]
proxy_util.c(3754): (54)Connection reset by peer: [client 127.0.0.1:51780]
AH03308: ap_proxy_transfer_between_connections: error on sock -
ap_get_brigade

[Thu Jan 05 11:04:28.001369 2017] [proxy:debug] [pid 65946]
proxy_util.c(2169): AH00943: WS: has released connection for (alfred.local)

Any idea what that might be about and if it is related?


2017-01-05 6:55 GMT-03:00 Yann Ylavic <yl...@gmail.com>:

> On Thu, Jan 5, 2017 at 10:36 AM, Yann Ylavic <yl...@gmail.com> wrote:
> >
> > For the record (after private discussion with Adam), it seems that a
> > configuration like the below would work for http(s) and ws(s) on the
> > same URL:
> >
> >   RewriteEngine on
> >   RewriteCond %{HTTP:Upgrade} "(?i)websocket"
> >   RewriteRule ^/(.*)$ wss://backend/$1 [P]
> >   ProxyPass / https://backend/
>
> *But* note that having both HTTP(s) and WS(s) on the same URL it is
> *not* recommended, mainly for security reasons.
>
> While mod_proxy_http is a strict HTTP protocol validator,
> mod_proxy_wstunnel is only a tunnel (a TCP proxy) once the upgrade is
> asked by the client/browser).
>
> So with the above configuration a simple Upgrade header in the request
> would open a tunnel with backend, including for "normal" HTTP traffic.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>

Re: [users@httpd] Web sockets & proxypass - No protocol handler was valid for the URL

Posted by Yann Ylavic <yl...@gmail.com>.
On Thu, Jan 5, 2017 at 10:36 AM, Yann Ylavic <yl...@gmail.com> wrote:
>
> For the record (after private discussion with Adam), it seems that a
> configuration like the below would work for http(s) and ws(s) on the
> same URL:
>
>   RewriteEngine on
>   RewriteCond %{HTTP:Upgrade} "(?i)websocket"
>   RewriteRule ^/(.*)$ wss://backend/$1 [P]
>   ProxyPass / https://backend/

*But* note that having both HTTP(s) and WS(s) on the same URL it is
*not* recommended, mainly for security reasons.

While mod_proxy_http is a strict HTTP protocol validator,
mod_proxy_wstunnel is only a tunnel (a TCP proxy) once the upgrade is
asked by the client/browser).

So with the above configuration a simple Upgrade header in the request
would open a tunnel with backend, including for "normal" HTTP traffic.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org