Search code examples
apache.htaccessmod-rewritemod-proxymod-proxy-wstunnel

Streaming video data to and from uberspace via nodejs and jsmpeg


I am trying to stream video data to and from uberspace via nodejs and jsmpeg.

My problem is that I'm getting a 404 when trying to access the url:

The requested URL /receive was not found on this server.

The url I am accessing is like this: https://stream.mydomain.com/receive

and this is my .htaccess:

DirectoryIndex disabled
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^send/(.*) http://localhost:61624/$1
RewriteRule ^receive/(.*) ws://localhost:61625/$1
</IfModule>

Solution

  • Two things here.

    1) This rule RewriteRule ^receive/(.*) ws://localhost:61625/$1 matches on /receive/xxx with a trailing slash after receive (xxx part as optional). So you need to access at least /receive/ in your case. Is it what you expect ? If not, simply adapt your rules.

    2) You need to use mod_proxy for both rules (use of the P flag)

    RewriteRule ^send/(.*)$ http://localhost:61624/$1 [P]
    RewriteRule ^receive/(.*)$ ws://localhost:61625/$1 [P]
    

    Note, though, that this method is not the fastest. If possible, use ProxyPass and ProxyPassReverse inside your apache config instead of an htaccess.