Search code examples
apacheproxymod-proxy

Preserve protocol in httpd proxy


I need to configure in Apache 2.4.9 (with mod_proxy and mod_proxy_wstunnel activated) a proxy with this mapping:

E.g.:

In other words, I need a proxy that keeps (preserves) the protocol.

This configuration does not work:

<VirtualHost *:80>
   ...
   ProxyRequests Off
   ProxyPreserveHost Off
   ProxyPass / http://my.backend:8080/
   ProxyPassReverse / http://my.backend:8080/
</VirtualHost>

because all request (no matter protocol) are proxied to http*

Anyone knows how can I solve this?

Thanks!


Solution

  • A posible solution is:

    RewriteEngine On
    RewriteCond %{HTTP:Upgrade} =WebSocket [NC,NV]
    RewriteRule ^/(.*) ws://my.backend:8080/$1 [P]
    RewriteRule ^/(.*) http://my.backend:8080/$1 [P]
    

    Source: http://mail-archives.apache.org/mod_mbox/httpd-dev/201405.mbox/%3C6FF4EBA7-866D-4D76-A10D-3D04B896EE87@jaguNET.com%3E