arut/nginx-rtmp-module

on_publish redirect happens, but fails to create hls directory

sachin-danpheit opened this issue · 0 comments

Goal is to achieve the renaming of stream directory as in #1705

The 302 redirect happens to http://host.docker.internal/username and the nginx/hls tries to create a directory but with the full url and errors out.

Why nginx/rtmp is trying to create folder with the full url instead of just creating with the returned username only?
How do I fix this?

[error] 29#29: *4 hls: mkdir() failed on '/var/www/live/http://host.docker.internal/username' (2: No such file or directory), client: 127.0.0.1, server: 0.0.0.0:1935

My nginx config

rtmp {
    server {
        listen 1935;
        listen [::]:1935 ipv6only=on;
        
        application app {
            live on;

            # Don't allow RTMP playback
            deny play all;

            # Push the stream to the local HLS application
            push rtmp://127.0.0.1:1935/hls;

            # The on_publish callback will redirect the RTMP
            # stream to the streamer's username, rather than their secret stream key.
            on_publish http://host.docker.internal:8000/start_stream;
            on_publish_done http://host.docker.internal:8000/stop_stream;
        }

        application hls {
            live on;

            # Only accept publishing from localhost.
            # (the `app` RTMP ingest application)
            allow publish 127.0.0.1;
            # allow publish all;
            deny play all;

            # Package streams as HLS
            hls on;
            hls_path /var/www/live;
            hls_nested on;
            hls_fragment_naming system;
            hls_datetime system;
        }
    }
}

Originally posted by @sachin-danpheit in #1705 (comment)