nginx rtm "server_name" directive is not allowed

190 Views Asked by At

My nginx configuring is below:

rtmp {
        server {
                listen 1935;
                chunk_size 4096;

                application live {
                        live on;
                        record off;
                        hls on;
                        hls_path /var/www/html/stream/hls;
                        hls_fragment 3;
                        hls_playlist_length 60;
                }
        }
}

Above code was worked well, but when I have bind domain with server_name, then it doesn't work.

rtmp {
        server {
                listen 1935;
                server_name example.com;
                chunk_size 4096;

                application live {
                        live on;
                        record off;
                        hls on;
                        hls_path /var/www/html/stream/hls;
                        hls_fragment 3;
                        hls_playlist_length 60;
                }
        }
}

above code is not working, coz, I have added server_name

getting this error:

nginx: [emerg] "server_name" directive is not allowed here in /etc/nginx/nginx.conf:95
nginx: configuration file /etc/nginx/nginx.conf test failed

Any faced same problem before? i googled, I couldn't find any solution for this?

anyone know this? how can I restrict to specific domain

0

There are 0 best solutions below