Skip to content
Snippets Groups Projects
Commit b84fcbf9 authored by shirenn's avatar shirenn 🌊
Browse files

[stream] \o fluxx.crans.org

parent 59c94288
No related branches found
No related tags found
1 merge request!80Stream
---
glob_nginx_rtmp:
uri: stream.crans.org
......@@ -25,6 +25,9 @@
# [test_vm]
# re2o-test.adm.crans.org
[nginx_rtmp]
fluxx.adm.crans.org
[reverseproxy]
hodaur.adm.crans.org
frontdaur.adm.crans.org
......@@ -81,6 +84,7 @@ gitlab-ci.adm.crans.org
hodaur.adm.crans.org
monitoring.adm.crans.org
boeing.adm.crans.org
fluxx.adm.crans.org
[ovh_physical]
sputnik.adm.crans.org
......
#!/usr/bin/env ansible-playbook
---
- hosts: nginx_rtmp
nginx_rtmp: "{{ glob_nginx_rtmp | combine(loc_nginx_rtmp) }}"
roles:
- nginx_rtmp
---
- name: restart nginx
service:
name: nginx
state: restarted
become: true
---
- name: Install nginx with rtmp module
apt:
name:
- nginx-full
- libnginx-mod-rtmp
register: apt_result
retries: 3
until: apt_result is succeeded
become: yes
- name: Copy module and site configuration files
template:
src: '{{ item }}.j2'
dest: '/etc/{{ item }}'
loop:
- nginx/modules-available/60-rtmp.conf
- nginx/sites-available/stream
notify: restart nginx
- name: Enable site
file:
src: '/etc/nginx/sites-available/stream'
dest: '/etc/nginx/sites-enabled/stream'
state: link
notify: restart nginx
- name: Enable module
file:
src: '/etc/nginx/modules-available/60-rtmp.conf'
dest: '/etc/nginx/modules-enabled/60-rtmp.conf'
state: link
notify: restart nginx
- name: Create site folder
file:
path: /var/www/stream/hls
state: directory
- name: Copy index configuration file
template:
src: index.html
dest: /var/www/stream/
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<title>Crans Live</title>
<link href="//unpkg.com/bootstrap@4.5/dist/css/bootstrap.min.css" rel="stylesheet">
<link href="//unpkg.com/video.js@7/dist/video-js.min.css" rel="stylesheet">
</head>
<body class="bg-dark m-2">
<div class="container">
<video id="my-video" class="video-js embed-responsive shadow-lg rounded-sm"></video>
</div>
<script src="//unpkg.com/video.js@7/dist/video.min.js"></script>
<script>
const videoId = window.location.pathname.split("/").pop()
videojs('my-video', {
controls: true,
autoplay: true,
preload: 'auto',
muted: true
}).src({
type: 'application/x-mpegURL',
src: `/hls/${videoId}.m3u8`
});
</script>
</body>
</html>
rtmp {
server {
listen 1935;
chunk_size 4096;
application live {
live on;
hls on;
hls_path /var/www/stream/hls/;
hls_fragment 3;
hls_playlist_length 60;
record off;
}
}
}
server {
listen 80;
listen [::]:80;
server_name {{ nginx_rtmp.uri }};
root /var/www/stream;
index index.html;
location / {
try_files $uri $uri/ /index.html;
}
location /hls {
# 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/dash+xml mpd;
application/vnd.apple.mpegurl m3u8;
video/mp2t ts;
}
}
}
rtmp {
server {
listen 1935;
chunk_size 4096;
application live {
live on;
record off;
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment