WWBN / AVideo

Create Your Own Broadcast Network With AVideo Platform Open-Source. OAVP OVP
https://avideo.tube/AVideo_OpenSource
Other
1.88k stars 970 forks source link

Streams , Ngnix #1852

Closed akhilleusuggo closed 5 years ago

akhilleusuggo commented 5 years ago

Step 7 from the guide : ( restart Ngnix ) sudo /usr/local/nginx/sbin/nginx

Error nginx: [emerg] invalid port in url "https://tube.akhilleusuggo.com/plugin/Live/on_publish.php" in /usr/local/nginx/conf/nginx.conf:24

My config

worker_processes  1;
    error_log  logs/error.log debug;
    events {
            worker_connections  1024;
    }
    rtmp {
            server {
                    listen 1935;
                    allow play all;
                    #creates our "live" full-resolution HLS videostream from our incoming encoder stream and tells where to put the HLS video manifest and video fragments
                    application live {
                            allow play all;
                            live on;
                            #record all;
                            #record_path /video_recordings;
                            #record_unique on;
                            hls on;
                            hls_nested on;
                            hls_path /HLS/live;
                            #hls_playlist_length 4s;
                            #hls_fragment 1s;
                            hls_fragment 10s;
                            on_publish https://tube.akhilleusuggo.com/plugin/Live/on_publish.php;
                            on_play https://tube.akhilleusuggo.com/plugin/Live/on_play.php;
                            on_record_done https://tube.akhilleusuggo.com/plugin/Live/on_record_done.php;
                    }
            }
    }
    http {
            include       mime.types;
            default_type  application/octet-stream;
            server {
                    listen 8080;
                    server_name localhost;
                    #creates the http-location for our full-resolution (desktop) HLS stream - "http://my-ip/live/my-stream-key/index.m3u8"      
                    location /live {
                            # Disable cache
                            add_header 'Cache-Control' 'no-cache';
Donnerstein commented 5 years ago

Engine-x does not support calling https URLs! I solved it so that I have set up an additional Apache vhost, which allows access to the site via another port without SLL.

DanielnetoDotCom commented 5 years ago

@Donnerstein is correct. you must use http instead https

akhilleusuggo commented 5 years ago

@Donnerstein , @DanielnetoDotCom Thank you for the info ... Now my site is not working anymore , since I had installed ISPconfig ( Apache2 ) , after installing Nginx my site and panel stop working. Looks like it's a port conflict and I don't know how to restore/change . Looking at the guide* of Daniel , he mentions something about having installed Nginx with Apache on port 81 , but didn't gave enough details to understand .

Donnerstein commented 5 years ago

Well, if that does not work anymore, then first stop nginx, "service nginx stop" or "/usr/local/nginx/sbin/nginx -s stop" and then start apache2 again.

In nginx.conf, the ports are specified with "listen". The http section "http {" tells the nginx which ports to use, of course a port can only be used by one service at a time. In the standard installation Apache2 uses the ports 80 and 443. the Nginx must therefore use other ports, in the guidance is the 8080.

Since they tried to invoke an https URL, I think that your page itself uses https, in this case also nginx must enable an https connection, because otherwise the bwoser later refuse to call the m3u8 file if it lies on an unencrypted URL. I'll tell you my nginx.conf and others which are working with a https streamer page. I hope you can derive from these findings.

To assign the apache an additional vhost with a different port, you can copy the standard vhost from the Apache2 file and adjust it accordingly. Of course, apache must of course open the port they want to use at the start, which must then also be specified in /etc/apache2/port.conf.

-----------nginx.conf---------------------

 worker_processes  1;
    error_log  logs/error.log debug;
    events {
            worker_connections  1024;
    }
    rtmp {
            server {
                    listen 1935;
                    allow play all;
                    chunk_size 4096; 
            application live {
                            allow play all;
                            live on;
                            hls on;
                            hls_nested on;
                            hls_path /HLS/live;
                            hls_fragment 10s;
                            on_publish http://localhost:1936/plugin/Live/on_publish.php;
                            on_play http://localhost:1936/plugin/Live/on_play.php;
                            on_record_done http://localhost:1936/plugin/Live/on_record_done.php;
                recorder video{
                record all;
                record_path /var/www/live_speicher;
                record_notify on;
                record_max_size 4096M; 
                record_suffix -%d-%b-%y-%T.flv;
                    }

                    }

            }
    }
    http {
            include       mime.types;
            default_type  application/octet-stream;
            server {
                    listen 8080;
                    listen 444 ssl;
            server_name you_domain.com;

               ssl_certificate               /etc/ssl/apache.cert;
            ssl_certificate_key        /etc/ssl/apache.key;
            ssl_protocols       TLSv1 TLSv1.1 TLSv1.2;
            ssl_ciphers         HIGH:!aNULL:!MD5;
            location /live {
                            # Disable cache
                            add_header 'Cache-Control' 'no-cache';

                            # CORS setup
                            add_header 'Access-Control-Allow-Origin' '*' always;
                            add_header 'Access-Control-Expose-Headers' 'Content-Length';

                            # allow CORS preflight requests
                            if ($request_method = 'OPTIONS') {
                                    add_header 'Access-Control-Allow-Origin' '*';
                                    add_header 'Access-Control-Max-Age' 1728000;
                                    add_header 'Content-Type' 'text/plain charset=UTF-8';
                                    add_header 'Content-Length' 0;
                                    return 204;
                            }
                            types {
                                    application/vnd.apple.mpegurl m3u8;
                            }
                            alias /HLS/live;
                    }
                    #allows us to see how stats on viewers on our Nginx site using a URL like: "http://my-ip/stats"     
                    #location /stats {
                    #        stub_status;
                    #}
                    location /stat {
                            rtmp_stat all;
                            rtmp_stat_stylesheet stat.xsl;
                    }
                    location /stat.xsl {
                            root html;
                    }
                    location /control {
                            rtmp_control all;
                    }
                    #allows us to host some webpages which can show our videos: "http://my-ip/my-page.html"     
                    location / {
                            root   html;
                            index  index.html index.htm;
                    }   
            }
    }

---------------ports.conf---------------------

 Listen 80
 Listen 1936

 <IfModule ssl_module>
    Listen 443
 </IfModule>

 <IfModule mod_gnutls.c>
    Listen 443
 </IfModule>

--------------VHost-----------------

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    Redirect / https://you_domain.com/

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

<VirtualHost *:1936>
    ServerAdmin webmaster@localhost
    ServerName you_domain.com
    ServerAlias you_domain.com
    ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
    DocumentRoot /var/www

</VirtualHost>

<VirtualHost *:443>

ServerName you_domain.com
ServerAlias you_domain.com
ServerAdmin webmaster@localhost

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

RewriteEngine on
SSLEngine on
SSlCertificateFile      /etc/ssl/apache.cert
SSlCertificatekeyFile   /etc/ssl/apache.key
SSlCertificateChainFile /etc/ssl/apache.ca
DocumentRoot /var/www

</VirtualHost>
akhilleusuggo commented 5 years ago

@Donnerstein Could you type the commends to edit files you're linking. On my case the port 8080 is used by ISPConfig . So can I use another port ?

akhilleusuggo commented 5 years ago

/etc/apache2/port.conf file doesn't exist

akhilleusuggo commented 5 years ago

my config is missing this part

recorder video{ record all; record_path /var/www/live_speicher; record_notify on; record_max_size 4096M; record_suffix -%d-%b-%y-%T.flv;

Donnerstein commented 5 years ago

Not so easy to fulfill if I do not know the system.

nginx.conf nano /usr/local/nginx/conf/nginx.conf The ports can also be specified in nano /etc/httpd/conf/httpd.conf if it exists.

My .conf file is an example. They do not need the recorder part, unless they want to use the SendToEncorder plugin. or record the streams for other reasons.

recorder video{
            record all;
            record_path /var/www/live_speicher;
            record_notify on;
            record_max_size 4096M; 
            record_suffix -%d-%b-%y-%T.flv;
                }

"recorder video" and the two curly brackets together with content. Need only if you want to record the stream

It does not matter which ports you use, by calling sudo netstat -tulpen you can see the opened ports and their services. Of course, if you're using a different port, you'll need to adjust the URLs in the live plugin as well

akhilleusuggo commented 5 years ago

@Donnerstein The site is back again , the issue was the :

  1. in case you use a HTTPS connnection you may need to Enable secure WebSocket sudo nano /etc/apache2/mods-available/proxy.conf

Make the file looks like this

<IfModule mod_proxy.c>
        ProxyPass /wss/ ws://127.0.0.1:8888/
</IfModule>

Clicking on streaming , is not recognizing my site ''link'' . I can't send it to you , because I'm still facing the same problem from the start of use YouPHPTube . If the user it's an admin , the page just don't wanna load to any other directory of the site . And I can't see any errors

Donnerstein commented 5 years ago

The proxy pass is only for live chat, but has to do with the rest of the page. I think I do not understand what you mean. So the link to the livestream site does not work.

akhilleusuggo commented 5 years ago

@Donnerstein I wanna ask you something that has nothing to do with Nginx , because before the streaming site , I need to fix this . I'm just tired of it .

When I create a new user , the page work perfectly . When I log with the admin , the page just get stuck , it wont reload anything , not a video , not the admin panel nothing . Even if I close the browser and reopen it , the page just loading and loading loop . Opening a incognito window , typing the site > the site loads . Login ad admin > page stuck again . Created a new user > Work perfect >When to DB > Gave to user Admin ( Value 1 ) > Again page and user stuck

Any solution ? Why I'm telling you this ? Cause I can't load the streaming page , I can not enter to url of the streaming page , just stuck

Donnerstein commented 5 years ago

I do not know the source code that exact. When it comes to the system, I can say something, but I can not think of anything about the site itself. Maybe @DanielnetoDotCom has an idea there.

akhilleusuggo commented 5 years ago

I managed to ender somehow , but look at the links image

Donnerstein commented 5 years ago

Player URL It must be the public address of the Nginx server. so https: //tube.akhilleusuggo.com/:444/live/... the nginx must be available on the port 444 with the ssl mod.

Live URL The address of the page on which the video is played for the stream.

Embeded, the same just embedding.

Server URL Here the rtmp protocol must be specified. Standard port is 1935. Therefore the port specification is not necessary here. It must be the public address of the nginx server. rtmp://tube.akhilleusuggo.com/live?p=...

These data can be changed in the live Plugin

akhilleusuggo commented 5 years ago

@Donnerstein Can I have the Nginx on another server and the YouPHPTube site on another server ?

DanielnetoDotCom commented 5 years ago

Yes you can, but the SendRecordedToEncoder plugin will not work if they are in a separated server

akhilleusuggo commented 5 years ago

@DanielnetoDotCom But if the encoder is on the Nginx server?

DanielnetoDotCom commented 5 years ago

to make the plugin SendRecordedToEncoder work, the Streamer, and the live server must be on the same