LINUX.ORG.RU

NGINX Stream server

 


0

1

Здравствуйте, есть проблема, ломаю голову и уже зашел в тупик, куда копать ... суть вопроса: есть ubuntu server 18.04.2, на нем развернут nginx stream и на нем же запущена страничка для теста стрима ip камеры. Перепробывал разные сборки конфигов nginx, все работает, камера стримется, и также со странички на video-js все идет, НО только внутри локально, из интернета если заходить, на страничку попадаю, ее вижу, но сам стрим поток уже не транслируется ... из оборудования, маршрутизатор mikrotik потры к серверу прокиныл 80 и 1925 (хотя по последнему все равно ничего не идет)


Ну так определи по какому порту идёт видео. Wireshark в помощь.

ox55ff ★★★★★
()

user www-data; worker_processes 1; pid /run/nginx.pid; include /etc/nginx/modules-enabled/*.conf;

events { worker_connections 768; # multi_accept on; }

http { sendfile off; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; # server_tokens off;

# server_names_hash_bucket_size 64; # server_name_in_redirect off;

include /etc/nginx/mime.types; default_type application/octet-stream;

access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log;

gzip on;

# gzip_vary on; # gzip_proxied any; # gzip_comp_level 6; # gzip_buffers 16 8k; # gzip_http_version 1.1; # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

include /etc/nginx/conf.d/*.conf; include /etc/nginx/sites-enabled/*; }

rtmp { server { listen 1935; chunk_size 8192;

application live { live on; interleave off; meta on; wait_key on; wait_video on; idle_streams off; sync 300ms; session_relay on; allow publish all; # deny publish all; # disable consuming the stream from nginx as rtmp # # deny play all; allow play all; #respawn on; #respawn_timeout 10s; # drop_idle_publisher 60s;

## == RECORDING OPTIONS: OFF/ALL == ## # default recorder # record off; record_suffix all-%d-%b-%y-%T.flv; record_path /var/www/recordings; record_max_size 4096M; record_unique on; record_append off; record_lock on;

## == FORWARD STREAM (OPTIONAL) == ## # == == TWITCH RE-STREAM == == # # push rtmp://live-ams.twitch.tv/app/LIVESTREAM_KEY; # == == YOUTUBE RE-STREAM == == # # push rtmp://a.rtmp.youtube.com/live2/LIVESTREAM_KEY; # == == MIXER.com RE-STREAM == == # # push rtmp://ingest-ams.mixer.com:1935/beam/LIVESTREAM_KEY;

publish_notify off; # play_restart off; # on_publish http://your-website/on_publish.php; # on_play http://your-website/on_play.php; # on_record_done http://your-website/on_record_done.php;

## == HLS == ## hls on; hls_nested on; hls_path /var/www/hls/live; # hls_base_url http://abc.de:1953/hls; hls_playlist_length 60s; hls_fragment 10s; hls_sync 100ms; hls_cleanup on;

## == DASH == ## dash on; dash_nested on; dash_path /var/www/dash; dash_fragment 10s; dash_playlist_length 60s; dash_cleanup on;

# == creates the downsampled or «trans-rated» mobile video stream as a 400kbps, re-sized video == # # exec ffmpeg -i rtmp://localhost/$app/$name -acodec copy -c:v libx264 -preset veryfast -profile:v baseline -vsync cfr -vf scale=-2:360,setdar=16:9 -b:v 400k -bufsize 400k -threads 0 -r 30 -f flv rtmp://localhost/low/${name};

# https://selimatmaca.com/index.php/live-streaming/165-adaptive-bitrate-streami... # }

# application liveout { # live on; # hls on; # hls_path /var/www/hls/liveout; # hls_fragment 10s; # hls_playlist_length 60s; # allow play all; # allow publish 127.0.0.1; # allow publish 192.168.0.117; # allow publish 192.168.0.0/24; # deny publish all;

# # hls_variant _240 BANDWIDTH=288000; # hls_variant _360 BANDWIDTH=448000; # hls_variant _480 BANDWIDTH=1152000; # hls_variant _720 BANDWIDTH=2048000; # # hls_variant _1080 BANDWIDTH=4096000; # }

application hls { live on; allow play all; hls on; hls_path /var/www/hls; hls_fragment 10s; hls_playlist_length 60s; }

exec_static ffmpeg -i rtsp://admin:!k38cm4id@192.168.1.115:554/Streaming/Channels/2/ -c copy -f flv rtmp://localhost:1935/hls/live; # Creates «mobile» lower-res HLS videostream from ffmpeg-created stream and where to put the manifest and video fragments # application low { live on; allow play all; hls on; hls_nested on; hls_path /var/www/hls/low; hls_fragment 10s; hls_playlist_length 60s; }

# application ipcam { # live on; # exec_pull ffmpeg -i rtsp://192.168.4.250:554/h264.sdp -c copy -f flv rtmp://localhost/ipcam/h264; # exec_pull ffmpeg -i rtsp://192.168.4.250:554/mjpeg.sdp -c copy -f flv rtmp://localhost/ipcam/mjpeg; # }

# Allows playing earlier recorded files # application vod { play /var/www/recordings; allow play all; } application vod_http { play http://192.168.0.117/recordings; allow play all; } # application vod_mirror { # # try local location first, then access remote location # play /var/www/recordings http://yourserver.ddns.net/vods; # } } }

jonia
() автор топика

## # You should look at the following URL's in order to grasp a solid understanding # of Nginx configuration files in order to fully unleash the power of Nginx. # https://www.nginx.com/resources/wiki/start/ # https://www.nginx.com/resources/wiki/start/topics/tutorials/config_pitfalls/ # https://wiki.debian.org/Nginx/DirectoryStructure # # In most cases, administrators will remove this file from sites-enabled/ and # leave it as reference inside of sites-available where it will continue to be # updated by the nginx packaging team. # # This file will automatically load configuration files provided by other # applications, such as Drupal or Wordpress. These applications will be made # available underneath a path with that package name, such as /drupal8. # # Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples. ##

# Default server configuration # server { listen 8080 default_server; # listen [::]:80 default_server;

listen 4433 ssl default_server; # listen [::]:4438 ssl default_server; # include snippets/snakeoil.conf;

# ssl_certificate /etc/letsencrypt/live/gorod.tk/fullchain.pem; # managed by Certbot # ssl_certificate_key /etc/letsencrypt/live/gorod.tk/privkey.pem; # managed by Certbot

root /var/www/html;

# Add index.php to the list if you are using PHP index index.php index.html index.htm;

server_name localhost;

location / { # root /var/www/html; # index index.php index.html index.htm; # First attempt to serve request as file, then as directory, then fall back to displaying a 404. try_files $uri $uri/ =404; }

location ~ \.php$ { try_files $uri =404; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }

# location ~ \.php$ { # include snippets/fastcgi-php.conf; # With php-fpm (or other unix sockets): # fastcgi_pass unix:/var/run/php/php7.3-fpm.sock; # With php-cgi (or other tcp sockets): # fastcgi_pass 127.0.0.1:80; # }

#error_page 500 502 503 504 /50x.html; #location = /50x.html { # root /var/www/html; #}

location ~ /\.ht { deny all; }

#location ~ \.(?:css(\.map)?|js(\.map)?|jpe?g|png|gif|ico|cur|heic|webp|tiff?|mp3|m4a|aac|ogg|midi?|wav|mp4|mov|webm|mpe?g|avi|ogv|flv|wmv|mpd|m3u8)$ { # expires 7d; # access_log off; # log_not_found off; # } #location ~ \.(?:svgz?|ttf|ttc|otf|eot|woff|woff2)$ { # add_header Access-Control-Allow-Origin «*»; # expires 7d; # access_log off; # }

# This provides RTMP statistics in XML at http://your-server-address/stat location /stat { rtmp_stat all; rtmp_stat_stylesheet stat.xsl; auth_basic «Restricted Content»; auth_basic_user_file /etc/nginx/.htpasswd; } # XML stylesheet to view RTMP stats. Copy stat.xsl wherever you want and put the full directory path here location /stat.xsl { root /var/www/html/; } # Control interface (extremely useful, but can also boot people from streams so we put basic auth in front of it - see https://github.com/arut/nginx-rtmp-module/wiki/Control-module for more information) # location /control { # # you'll need a htpasswd auth file, that's outside the scope of this doc but any apache one will work # auth_basic «stream»; # auth_basic_user_file /etc/nginx/.htpasswd; # rtmp_control all; # }

# allows us to see how stats on viewers on our Nginx site using a URL like: "http://my-ip/stats" # location /stub_status { # stub_status; # allow 127.0.0.1; # deny all; # } #creates the http-location for our full-resolution (desktop) HLS stream - "http://my-ip/live/my-stream-key/index.m3u8"

#

jonia
() автор топика

========================================== RTMP =================================== # location /live { # root /var/www/; alias /var/www/hls/live; expires -1; autoindex on; autoindex_localtime on; # CORS setup # set $sent_http_accept_ranges bytes; add_header 'Cache-Control' 'no-cache'; add_header Cache-Control no-cache; 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; application/dash+xml mpd; video/mp2t ts; } }

location /hls { root /var/www; # alias /var/www/hls; expires -1; autoindex on; autoindex_localtime on; # CORS setup # set $sent_http_accept_ranges bytes; add_header Cache-Control no-cache; 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; application/dash+xml mpd; video/mp2t ts; } } # mpeg-dash for HTML5, HTTP side. nginx stores DASH fragments here, so make sure it's writable by nginx location /dash { # root /var/www; alias /var/www/dash; autoindex on; autoindex_localtime on; # CORS setup # set $sent_http_accept_ranges bytes; add_header Cache-Control no-cache; 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/x-mpegURL m3u8; application/dash+xml mpd; video/mp2t ts; video/mp4 mp4; } } # creates the http-location for our mobile-device HLS stream - "http://my-ip/low/my-stream-key/index.m3u8" location /low { # root /var/www/hls; alias /var/www/hls/low; expires -1; autoindex on; autoindex_localtime on; # CORS setup # set $sent_http_accept_ranges bytes; add_header Cache-Control no-cache; 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; application/dash+xml mpd; video/mp2t ts; video/mp4 mp4; } }

location /recordings { alias /var/www/recordings/; # root /var/www/recordings; autoindex on; autoindex_localtime on; # CORS setup # set $sent_http_accept_ranges bytes; add_header Cache-Control no-cache; 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; application/dash+xml mpd; video/mp2t ts; video/mp4 mp4; } } }

jonia
() автор топика
Ответ на: комментарий от jonia

Внизу каждой страницы и каждого комментария при письме есть ссылка на разметку, причем подобная ей много где используется.

www.linux.org.ru/help/lorcode.md

[code][/code]

Vsevolod-linuxoid ★★★★★
()
Последнее исправление: Vsevolod-linuxoid (всего исправлений: 1)
Ответ на: комментарий от Vsevolod-linuxoid

Спасибо ... а я попытался вставить через

jonia
() автор топика

Вроде понял где у меня грабли .... если напрямую выставлять ссылку на стрим, то все прекрасно показывается, но тут получается прямаю ссылка тупо на стрим сервер, которую можно и так вбить .. а вот чтобы все работало посредством сайта, я понял что нужно сделать проксирование между серверами и в мир ? связка получается stream server nginx далее web server nginx + apache и уже книму идет обращение из мира

jonia
() автор топика
Вы не можете добавлять комментарии в эту тему. Тема перемещена в архив.