Connecting OBS-STUDIO to Nginx server - nginx

I have installed and started the Nginx server on Ubuntu 14.04. My objective is to stream a video (live) using HLS (HTTP live streaming). I followed this tutorial https://www.vultr.com/docs/setup-nginx-on-ubuntu-to-stream-live-hls-video, and it recommends using OBS-STUDIO. However, I don't know how to stream from the OBS-STUDIO to the Nginx and then view the stream from other machines (e.g. with VLC).

Add a media source for OBS.
Configure the self-defined media server on OBS, add a URL as follows:
URL: rtmp://domain_name:1935/hlslive
stream name: test
Build Nginx with nginx-rtmp-module ,install, and then config nginx.conf
vim /usr/local/nginx/conf/nginx.conf
add or config the following module:
rtmp {
server {
listen 1935; #listen port
chunk_size 4096;
application hlslive { #rtmp push stream request path
live on;
hls on;
hls_path /usr/share/nginx/html/hlslive/test;
hls_fragment 3s;
hls_playlist_length 18s;
}
}
}
also config as a http server for hls m3u8 request:
http {
...
server {
listen 8080;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root /usr/share/nginx/html;
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;
}
}
}
run nginx
nginx -c /usr/local/nginx/conf/nginx.conf
Click Begin Push Stream on OBS.
Input the following URL to view the live video.
http://domain_name:8080/hlslive/test/test.m3u8

Related

Javascript and Css file is not loading while using proxy_pass of Nginx

I have an angular application (say admin app) running at port 4200 in my windows machine. My Nginx is running at port 8080. When request is coming at Nginx I am forwarding it to my angular application (admin app, port 4200) but in that case Js and Css files are not rendered for the admin app and showing 404 error for all css/js files.
My operating System is windows 10
Here is my configuration at nginx.conf file:
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 8080 ;
server_name localhost;
location /admin {
proxy_pass http://localhost:4200/;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
here is the error picture

configure nginx to return 503 error code for all page except home page

One of my client is suspending the site for few months, so I am planning to set a landing page for the home page and return a 503 status code to all other links. (I read that returning 503 status code wont harm the seo )
How can this be possible via nginx config?
i have the following nginx config with me but it throw 503 for all request.
server {
listen 80;
listen [::]:80;
server_name localhost;
#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;
location / {
return 503;
}
}
is it possible to configure nginx config to serve an index.html page at the doc root /usr/share/nginx/html and retrun 503 on all other link? what will be the nginx conf then?
Use the exact match location:
location = / {
root /usr/share/nginx/html;
index index.html;
}
# all the other requests will be served with the following location
location / {
return 503;
}

Setting up nginx to stream HLS/RTMP simultaneously

I have an nginx web server with the RTMP module running perfectly and pushing out video to several RTMP destinations (Facebook, YouTube, Periscope, etc.).
I now need the stream to output in the HLS protocol so I can build a custom player for it without flash dependency. I've tried following a few other tutorials, but I am struggling.
I have the default config file that came with the installation of nginx with the following added to the end:
rtmp {
server {
listen 1935;
chunk_size 4096;
application live {
live on;
record off;
push rtmp://<streaming-service/key>
}
}
}
What exactly do I need to add to this config file to retain my ability to push out video to these RTMP destinations as well as have a HLS feed I can use in a player without Flash?
I already have FFMPEG installed on the machine in order to send video to Periscope. I've seen solutions that do not need FFMPEG, but I just wanted to add that I did have it installed and am somewhat familiar with it.
EDIT: for more information, I am sending video through the server via a Teradek encoder.
I solved this with FFMPEG. The pull directive wasn't working properly. Here's the config file that worked for me:
#user nobody;
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
server {
listen 80;
server_name localhost;
location /hls {
types {
application/vnd.apple.mpegurl m3u8;
video/mp2t ts;
}
root /tmp/;
add_header Cache-Control no-cache;
add_header 'Access-Control-Allow-Origin' '*';
}
location / {
root html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
rtmp {
server {
listen 1935;
chunk_size 4096;
application live {
live on;
record off;
push rtmp://<location/key>
exec ffmpeg -i rtmp://localhost/live/test -vcodec libx264 -vprofile baseline -x264opts keyint=40 -acodec aac -strict -2 -f flv rtmp://localhost/hls/test;
}
application hls {
live on;
hls on;
hls_path /tmp/hls/;
hls_fragment 6s;
hls_playlist_length 60s;
}
}
}

Custom Livestream Platform For DJI Phantom 4 Pro+

Edit : Here's my ufw status:
Status: active
To Action From
-- ------ ----
80 ALLOW Anywhere
1935 ALLOW Anywhere
80 (v6) ALLOW Anywhere (v6)
1935 (v6) ALLOW Anywhere (v6)
And App List:
Available applications:
CUPS
So, I tweaked with DJI Phantom 4 Pro+ and discovered that it support custom stream platform. My question is how to do it? I can already create NginX RTMP server but I still can't figure out how to make the Drone connect and stream to it. I already test my server using OBS to http://{IP}/live with key test and open it using VLC (on my phone) at rtmp://{IP}/live/test. Here's my nginx conf:
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 192.168.0.39:80;
server_name localhost;
location / {
root html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
rtmp {
server {
listen 192.168.0.39:1935;
chunk_size 4096;
application live {
live on;
record off;
}
}
}
It turns out I'm just stupid. To anyone who has the same issue, don't make the same mistake as I did. I enter rtmp://{IP}/live/drone/. It should be rtmp://{IP}/live/drone (notice the missing "/")

NGINX web server configuration

I've just downloaded NGINX for Windows and I'm struggeling a bit.
It's up and running with my index file showing at 127.0.0.1:8080, but I'm having problems with connection my web server to my domain.
From what I understand from the documentation I've read online, I had to change the DNS properties at my registrar like this (target-IP is my public IP):
Here is my nginx.conf file:
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 8080;
server_name erikbugge.no www.erikbugge.no;
location / {
root www;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root www;
}
}
}
I have also port-forwarded port 8080 to my local IP address in my router.
The problem now is that whenever I'm trying to access my webpage www.erikbugge.no it simply redirects me to my public IP address.
I'm pretty sure I'm doing something wrong, but I have no idea what it is.
Please be gentle, I'm new to this web server stuff.

Resources