Home > other >  Continue to ask nginx RTMP - module client push flow permission problems
Continue to ask nginx RTMP - module client push flow permission problems

Time:09-20

http://pengwei.me/nginx-rtmp-secure-your-nginx-server/
Online have a solution to this problem, but I have been tested on centos and Windows, on_publish parameter is the effect, if you don't through validation of PHP page, is able to prevent the client push flow, but, as the paper said, obs pushed through to the address of the client, such as: RTMP://X.X.X.X/live/test? User=x& Pass=x, address parameter, PHP is the validation page to accept less than, so still not achieve the effect,

Could have achieved greatly, please inform the specific method? Online etc.!

CodePudding user response:

Someone made similar nginx - RTMP push flow access control?

CodePudding user response:

Online are tried, not to his study for a day, several times tests, found that the problem is acquiring parameters, you should not use _GET, the correct way is to use _POST:

The code is as follows:
In setting on_publish nginx module configuration file
Nginx. Conf
RTMP {
Server {
Listen, 1935;
Ping 30 s;
Notify_method get;

Application myapp {
Live on.

On_publish http://localhost:8080/on_publish.php;
}
}

Description: http://localhost:8080/on_publish.php;
On_publish. PHP should be placed where you can execute PHP, port does not necessarily is 8080, is that you can run the PHP url and port

We then on_publish. PHP processing, for example:
On_publish. PHP

<? PHP

//? User=user& Pass=pass

@ $name=$_POST [' name '];
@ $pass=$_POST [' pass '];

$savename=test;
$savepass=password;

If (empty ($name) | | the empty ($pass)) {

Echo "string stream is not correct!" ;
The header (' HTTP/1.0 404 Not Found ').

} else {
If (STRCMP ($name, $savename)==0 & amp; & STRCMP ($pass, $savepass)==0) {
Echo "string stream right!" ;
} else {
Echo "string stream is not correct!" ;
The header (' HTTP/1.0 404 Not Found ').
}
}

?>


This code is a simple user authentication, authentication and add more parameters can also be changed to take database for validation,
Push the end of the service flow setting
With the Open Broadcaster Software (OBS), for example

1, FMS URL:
RTMP://localhost: 1935/myapp

2, play the path/string stream (if present) :
test? Pass=password

Which test for streamkey string stream, the name of the? Pass=password used for authentication (need to change the test to want in practical use, in the name of the password change password they want, for example, is set to 1234567890)

The client RTMP Settings:

RTMP://IP address: 1935/myapp/test

At 19:00 himself in the 2016-10-23 test success!

CodePudding user response:

Nginx - RTMP push flow access control, as long as the push control flow and control the key line of the name of the
Different flow corresponding to different keys

$name is nginx - RTMP - the built-in parameters in the module name, do not change

CodePudding user response:

reference mubx70 reply: 3/f
nginx - RTMP push flow access control, as long as the name of the push control flow and control the key line of
Different flow corresponding to different keys

$name is nginx RTMP - the built-in parameters in the module name, do not modify


Eldest brother, consult nginx. Conf should how to write, I was such a
 
Worker_processes 1;

# error_log logs/error log debug;

Events {
worker_connections 1024;
}

RTMP {
Server {
Listen, 1935;

Application test_rtmp_1 {live on. }
Application HLS {
Live on.
HLS on;
Hls_path temp/HLS;
Hls_fragment 8 s;
}
}
}

HTTP {
Server {
Listen, 8087;

The location/{
Root webroot.
}

The location/stat {
Rtmp_stat all;
Rtmp_stat_stylesheet stat. XSL;
}

The location/stat. XSL {
Root webroot.
}

The location/HLS {
# server HLS fragments could
Types {
Application/VND. Apple. Mpegurl m3u8;
Video/mp2t ts;
}
Alias temp/HLS;
Expires - 1;
}

}
}


But obs push streaming URL: when RTMP://192.168.1.151/live
Key: the test_rtmp_1

Obs:


So how to deal with, please, thank!

CodePudding user response:

The positive solution to http://blog.csdn.net/wei389083222/article/details/78721074

CodePudding user response:

Operating system: Windows 2003 server
Live web server + system: nginx 1.12.1 nginx RTMP - module 1.2.0
Pushed the flow equipment, mobile phone client, page flow, obs
Address: push flow RTMP://192.168.1.1:8090/live/test? Pass=123
The test for the user name, 123 for the password
What has happened is that live behind/no matter what can be introduced to write, although also triggered the publish. PHP page, now is regardless of the user, a database query, query the user what to do, no query to how to deal with, don't know what to write, there are instructions below program
Nginx. Conf configuration (part) :

Listen, 1935;
Notify_method POST;
Application live {

Live on.
Publish_notify on;
# when the device is pushing flow, triggering the publish. PHP
On_publish 192.168.1.1:8090/publish. PHP;

}

The publish. PHP file code:
<? PHP
@ $name=trim ($_REQUEST [] "name");
@ $pass=trim ($_REQUEST [" pass "]);

Added a//write file operations, is to verify whether triggered the publish the PHP file, did trigger the verification,
$myfile=fopen (" testfile. TXT ", "w");
//if not null values to perform a database query
if(! Empty ($name) and! Empty ($pass))
{
The require "function_php/function. PHP";
Conn ();//connect to the database to be obtained function
//query the database whether this user exists in
$SQL="select * from tbl_user where user_name='$name and user_pass=' $pass";
$query=$conn - & gt; The query ($SQL);
$row=$query - & gt; Num_rows;

If ($row==1)
{
//if there is a user the user name and password to a file, also wrote, indeed, the question now is to verify the correct later, don't know how to write, how to tell nginx. Conf file
Fwrite ($myfile. $name. "\ n");
Fwrite ($myfile, $pass. "\ n");
Fwrite ($myfile, $row. "\ n");

}
The else
{
//if the user does not exist and validation in the user name and password are written to a file is not correct what to write? How to stop pushing flow
Fwrite ($myfile. $name. "\ n");
Fwrite ($myfile, $pass. "\ n");
Fwrite ($myfile, $row. "\ n");

}
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related