Tuesday, 12 September 2023

RTMP HLS SSL NGINX CENTOS

 Berikut Conf nginx Centos 8

nginx.conf

# TRIMAN SEPTEMBER 2023 @M3U8,RTMP,SSL,HTML #
user nginx; 
worker_processes  auto;
error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;
pid        logs/nginx.pid;
rtmp_auto_push on;
include /usr/local/nginx/conf/stream/*.conf;
events {
    worker_connections  1024;
multi_accept on;
}
http {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;
    sendfile        on;
    #tcp_nopush     on;
    #keepalive_timeout  0;
    keepalive_timeout  65;
    #gzip  on;
    log_format isp '$bytes_sent $request_length';

    server {
        listen       80;
listen       443 ssl;
        server_name  ssl.us.ceriatv.co.id localhost;
        ssl_certificate      ssl.us.ceriatv.co.id.ca-bundle.pem;
        ssl_certificate_key  ssl.us.ceriatv.co.id.key;
        ssl_session_cache    shared:SSL:1m;
        ssl_session_timeout  5m;
        ssl_ciphers  HIGH:!aNULL:!MD5;
        ssl_prefer_server_ciphers  on;
        server_name  localhost;
        location /stat {
                rtmp_stat all;
                rtmp_stat_stylesheet stat.xsl;
        }
 
        location /stat.xsl {
                root /etc/nginx/;
        }

        location /dash {
                root /var/www/html;
                add_header Cache-Control no-cache;
        }

        location /hls {
                types {
                        application/vnd.apple.mpegurl m3u8;
                        video/mp2t ts;
                }
                root /var/www/html;
                add_header Cache-Control no-cache;
                add_header 'Access-Control-Allow-Origin' '*';
        }

        #charset koi8-r;
        #access_log  logs/host.access.log  main;

        location / {
                root /var/www/html;
                rtmp_control all;
                index  index.html index.htm;
        }

        #error_page  404              /404.html;
        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }


    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}


    # HTTPS server
    #
    #server {
    #    listen       443 ssl;
    #    server_name  localhost;
    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;
    #    ssl_session_cache    shared:SSL:1m;
    #    ssl_session_timeout  5m;
    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers  on;
    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}

}

rtmp.conf

# TRIMAN SEPTEMBER 2023 @M3U8,RTMP,SSL,HTML #
rtmp {
    #access_log /var/log/nginx/rtmp_access.log;
    server {
        listen 1955;
        ping 30s;
 
application hls {
allow play all;
            live on;
            hls on;
            hls_fragment 3s;
            hls_playlist_length 60;
            #hls_variant _low BANDWIDTH=160000;
            #hls_variant _mid BANDWIDTH=320000;
            #hls_variant _hi  BANDWIDTH=640000;
            #  hls_variant _160p BANDWIDTH=160000 RESOLUTION=284x160;
            #  hls_variant _240p BANDWIDTH=240000 RESOLUTION=360x240;
            #  hls_variant _360p BANDWIDTH=448000 RESOLUTION=640x360;
            #  hls_variant _720p BANDWIDTH=1152000 RESOLUTION=1280x720;
            #  hls_variant _1080p BANDWIDTH=2048000 RESOLUTION=1920x1080;
#  hls_variant _160p BANDWIDTH=160000 RESOLUTION=284x160;
            hls_path /var/www/html/hls;
        }
application dntv {
            live on;
            hls on;
            hls_fragment 3s;
            hls_playlist_length 60;
            hls_path /var/www/html/dntv;
            #exec_static ffmpeg -i "rtsp://127.0.0.1:1930/rvn/live" -c copy -f flv rtmp://127.0.0.1:1955/dntv/stream;
        }
application ceria {
            live on;
            hls on;
            hls_fragment 3s;
            hls_playlist_length 60;
            hls_path /var/www/html/ceria;
hls_variant _low BANDWIDTH=320000;
            hls_variant _mid BANDWIDTH=640000;
            hls_variant _hi  BANDWIDTH=1152000;
exec_static ffmpeg -i rtsp://103.30.246.47:1935/ceria/live
 -c copy -b:v 768K -s 720x400 -f flv rtmp://127.0.0.1:1955/ceria/stream_low
 -c copy -b:v 1024K -s 1280x720 -f flv rtmp://127.0.0.1:1955/ceria/stream_mid
 -c copy -b:v 1920K -s 1920x1080 -f flv rtmp://127.0.0.1:1955/ceria/stream_hi;
        }
application avtech {
            live on;
            hls on;
            hls_fragment 3s;
            hls_playlist_length 60;
            hls_path /var/www/html/avtech;
            hls_variant _160p BANDWIDTH=160000 RESOLUTION=284x160;
            hls_variant _360p BANDWIDTH=448000 RESOLUTION=640x360;
            hls_variant _720p BANDWIDTH=1152000 RESOLUTION=1280x720;
            hls_variant _1080p BANDWIDTH=2048000 RESOLUTION=1920x1080;
exec_static ffmpeg -i rtsp://127.0.0.1:1930/avtech/live.stream_720p 
 -c copy -f flv rtmp://127.0.0.1:1955/avtech/stream_160p
 -c copy -f flv rtmp://127.0.0.1:1955/avtech/stream_360p
 -c copy -f flv rtmp://127.0.0.1:1955/avtech/stream_720p
 -c copy -f flv rtmp://127.0.0.1:1955/avtech/stream_1080p;
        }
    }
}
===============================
# TRIMAN SEPTEMBER 2023 @M3U8,RTMP,SSL,HTML #
rtmp {
    #access_log /var/log/nginx/rtmp_access.log;
    server {
        listen 1955;
        ping 30s;
 
application hls {
allow play all;
            live on;
            hls on;
#hls_mp4_buffer_size     60s;
#hls_mp4_max_buffer_size 70s;
            hls_fragment 3s;
            hls_playlist_length 60;
#hls_variant _low BANDWIDTH=160000;
            #hls_variant _mid BANDWIDTH=320000;
            #hls_variant _hi  BANDWIDTH=640000;
            #  hls_variant _160p BANDWIDTH=160000 RESOLUTION=284x160;
            #  hls_variant _240p BANDWIDTH=240000 RESOLUTION=360x240;
            #  hls_variant _360p BANDWIDTH=448000 RESOLUTION=640x360;
            #  hls_variant _720p BANDWIDTH=1152000 RESOLUTION=1280x720;
            #  hls_variant _1080p BANDWIDTH=2048000 RESOLUTION=1920x1080;
#  hls_variant _160p BANDWIDTH=160000 RESOLUTION=284x160;
            hls_path /var/www/html/hls;
        }
application dntv {
            live on;
            hls on;
            hls_fragment 3s;
            hls_playlist_length 60;
            hls_path /var/www/html/hls/dntv;
            hls_variant _160p BANDWIDTH=160000 RESOLUTION=284x160;
            hls_variant _360p BANDWIDTH=448000 RESOLUTION=640x360;
            hls_variant _720p BANDWIDTH=1152000 RESOLUTION=1280x720;
            hls_variant _1080p BANDWIDTH=2048000 RESOLUTION=1920x1080;
exec_static ffmpeg -i rtsp://127.0.0.1:1930/rvn/live
 -c copy -f flv rtmp://127.0.0.1:1955/dntv/stream_160p
 -c copy -f flv rtmp://127.0.0.1:1955/dntv/stream_360p
 -c copy -f flv rtmp://127.0.0.1:1955/dntv/stream_720p
 -c copy -f flv rtmp://127.0.0.1:1955/dntv/stream_1080p;
        }
application ceria {
            live on;
            hls on;
            hls_fragment 3s;
            hls_playlist_length 60;
            hls_path /var/www/html/hls/ceria;
            hls_variant _160p BANDWIDTH=160000 RESOLUTION=284x160;
            hls_variant _360p BANDWIDTH=448000 RESOLUTION=640x360;
            hls_variant _720p BANDWIDTH=1152000 RESOLUTION=1280x720;
            hls_variant _1080p BANDWIDTH=2048000 RESOLUTION=1920x1080;
exec_static ffmpeg -i rtsp://103.30.246.47:1935/ceria/live
 -c copy -f flv rtmp://127.0.0.1:1955/ceria/stream_160p
 -c copy -f flv rtmp://127.0.0.1:1955/ceria/stream_360p
 -c copy -f flv rtmp://127.0.0.1:1955/ceria/stream_720p
 -c copy -f flv rtmp://127.0.0.1:1955/ceria/stream_1080p;
        }
application avtech {
            live on;
            hls on;
            hls_fragment 3s;
            hls_playlist_length 60;
            hls_path /var/www/html/hls/avtech;
            hls_variant _160p BANDWIDTH=160000 RESOLUTION=284x160;
            hls_variant _360p BANDWIDTH=448000 RESOLUTION=640x360;
            hls_variant _720p BANDWIDTH=1152000 RESOLUTION=1280x720;
            hls_variant _1080p BANDWIDTH=2048000 RESOLUTION=1920x1080;
exec_static ffmpeg -i rtsp://127.0.0.1:1930/avtech/live.stream_720p 
 -c copy -f flv rtmp://127.0.0.1:1955/avtech/stream_160p
 -c copy -f flv rtmp://127.0.0.1:1955/avtech/stream_360p
 -c copy -f flv rtmp://127.0.0.1:1955/avtech/stream_720p
 -c copy -f flv rtmp://127.0.0.1:1955/avtech/stream_1080p;
        }
application jektv {
            live on;
            hls on;
            hls_fragment 3s;
            hls_playlist_length 60;
            hls_path /var/www/html/hls/jektv;
            hls_variant _160p BANDWIDTH=160000 RESOLUTION=284x160;
            hls_variant _360p BANDWIDTH=448000 RESOLUTION=640x360;
            hls_variant _720p BANDWIDTH=1152000 RESOLUTION=1280x720;
            hls_variant _1080p BANDWIDTH=2048000 RESOLUTION=1920x1080;
exec_static ffmpeg -i rtmp://61.8.64.138:1935/jektv/myStream 
 -c copy -f flv rtmp://127.0.0.1:1955/jektv/stream_160p
 -c copy -f flv rtmp://127.0.0.1:1955/jektv/stream_360p
 -c copy -f flv rtmp://127.0.0.1:1955/jektv/stream_720p
 -c copy -f flv rtmp://127.0.0.1:1955/jektv/stream_1080p;
        }
    }
}

No comments:

Post a Comment