Skip to content
GitLab
Explorer
Connexion
Navigation principale
Rechercher ou aller à…
Projet
S
Server Rtmp
Gestion
Activité
Membres
Labels
Programmation
Tickets
0
Tableaux des tickets
Jalons
Wiki
Jira
Code
Requêtes de fusion
0
Dépôt
Branches
Validations
Étiquettes
Graphe du dépôt
Comparer les révisions
Extraits de code
Compilation
Pipelines
Jobs
Planifications de pipeline
Artéfacts
Déploiement
Releases
Registre de paquets
Opération
Environnements
Modules Terraform
Surveillance
Incidents
Service d'assistance
Analyse
Données d'analyse des chaînes de valeur
Contributor analytics
Données d'analyse CI/CD
Données d'analyse du dépôt
Expériences du modèle
Aide
Aide
Support
Documentation de GitLab
Comparer les forfaits GitLab
Forum de la communauté
Contribuer à GitLab
Donner votre avis
Raccourcis clavier
?
Extraits de code
Groupes
Projets
marketing confort
Server Rtmp
Validations
fc696f4d
Valider
fc696f4d
rédigé
il y a 9 mois
par
aftys
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
updated nginx conf
parent
fcb3efcd
Branches
Branches contenant la validation
Aucune requête de fusion associée trouvée
Modifications
5
Masquer les modifications d'espaces
En ligne
Côte à côte
Affichage de
5 fichiers modifiés
docker-install.sh
+0
-46
0 ajout, 46 suppressions
docker-install.sh
nginx.conf
+72
-22
72 ajouts, 22 suppressions
nginx.conf
register-live-api/recorder.js
+1
-1
1 ajout, 1 suppression
register-live-api/recorder.js
setup.sh
+203
-0
203 ajouts, 0 suppression
setup.sh
start.sh
+1
-1
1 ajout, 1 suppression
start.sh
avec
277 ajouts
et
70 suppressions
docker-install.sh
supprimé
100755 → 0
+
0
−
46
Voir le fichier @
fcb3efcd
#!/bin/bash
# Exit immediately if a command exits with a non-zero status
set
-e
# Update the apt package index
sudo
apt-get update
# Install packages to allow apt to use a repository over HTTPS
sudo
apt-get
install
-y
\
apt-transport-https
\
ca-certificates
\
curl
\
software-properties-common
# Add Docker's official GPG key
curl
-fsSL
https://download.docker.com/linux/ubuntu/gpg |
sudo
gpg
--dearmor
-o
/usr/share/keyrings/docker-archive-keyring.gpg
# Set up the stable repository
echo
\
"deb [arch=
$(
dpkg
--print-architecture
)
signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu
\
$(
lsb_release
-cs
)
stable"
|
sudo tee
/etc/apt/sources.list.d/docker.list
>
/dev/null
# Update the apt package index again
sudo
apt-get update
# Install the latest version of Docker CE and containerd
sudo
apt-get
install
-y
docker-ce docker-ce-cli containerd.io
# Install Docker Compose
sudo
curl
-L
"https://github.com/docker/compose/releases/download/
$(
curl
-s
https://api.github.com/repos/docker/compose/releases/latest |
grep
-oP
'"tag_name": "\K(.*)(?=")'
)
"
-o
/usr/local/bin/docker-compose
# Apply executable permissions to the Docker Compose binary
sudo chmod
+x /usr/local/bin/docker-compose
# Add the current user to the docker group
sudo
usermod
-aG
docker
$USER
# Print Docker version
docker
--version
# Print Docker Compose version
docker-compose
--version
echo
"Docker and Docker Compose have been installed successfully. Please log out and log back in to apply the Docker group changes."
This diff is collapsed.
Click to expand it.
nginx.conf
+
72
−
22
Voir le fichier @
fc696f4d
...
...
@@ -2,27 +2,33 @@ daemon off;
error_log
/dev/stdout
info
;
worker_processes
auto
;
# Automatically set worker processes based on CPU cores
events
{
worker_connections
4096
;
# Augmenter le nombre de connexions de travail
worker_connections
4096
;
# Increase worker connections for handling more clients
use
epoll
;
multi_accept
on
;
}
rtmp
{
server
{
listen
1935
;
chunk_size
8192
;
# Augmenter la taille des chunks pour améliorer les performances
allow
publish
all
;
application
live
{
live
on
;
record
off
;
hls
on
;
hls_path
/tmp/hls
;
hls_fragment
1
;
# Réduire la taille des fragments pour une latence plus faible
hls_playlist_length
5
;
# Réduire la longueur de la playlist pour une latence plus faible
hls_fragment_naming
system
;
hls_fragment_naming_granularity
2
;
hls_fragment_slicing
aligned
;
server
{
listen
1935
;
chunk_size
8192
;
# Increase chunk size for better throughput
application
live
{
live
on
;
record
off
;
# HLS settings
hls
on
;
hls_path
/dev/shm/hls
;
# Use a memory-based path for HLS
hls_fragment
1
;
# Short fragment size for lower latency
hls_playlist_length
10
;
# Increase playlist length for better buffering
hls_fragment_naming
system
;
hls_fragment_naming_granularity
2
;
hls_fragment_slicing
aligned
;
}
}
}
}
http
{
...
...
@@ -35,18 +41,35 @@ http {
keepalive_timeout
65
;
types_hash_max_size
2048
;
gzip
on
;
# Enable gzip compression
gzip
on
;
gzip_types
text/plain
application/xml
application/json
text/css
application/javascript
;
server
{
listen
443
ssl
;
server_name
hls.mydressin-server.com
;
ssl_certificate
/usr/local/nginx/conf/ssl/PositiveSSL_Wildcard_mydressin-server.com.pem
;
ssl_certificate_key
/usr/local/nginx/conf/ssl/PositiveSSL_Wildcard_mydressin-server.com.pem
;
location
/hls
{
types
{
application/vnd.apple.mpegurl
m3u8
;
}
root
/dev/shm
;
# Ensure root matches the memory-based HLS path
add_header
Cache-Control
no-cache
;
add_header
Access-Control-Allow-Origin
*
;
# Allow all origins
add_header
Access-Control-Allow-Methods
'GET,
HEAD,
OPTIONS'
;
# Allow specific methods
add_header
Access-Control-Allow-Headers
'*'
;
# Allow all headers
expires
-1
;
}
location
/dash
{
root
/tmp
;
add_header
Cache-Control
no-cache
;
add_header
Access-Control-Allow-Origin
*
;
expires
-1
;
# Désactiver la mise en cache pour les fichiers HLS
add_header
Access-Control-Allow-Methods
'GET,
HEAD,
OPTIONS'
;
add_header
Access-Control-Allow-Headers
'*'
;
expires
-1
;
}
location
/stat
{
...
...
@@ -59,14 +82,41 @@ http {
}
location
/control
{
rtmp_control
all
;
add_header
Access-Control-Allow-Origin
*
always
;
}
rtmp_control
all
;
add_header
Access-Control-Allow-Origin
*
always
;
}
location
/
{
root
html
;
index
index.html
index.htm
;
}
}
}
server
{
listen
80
;
server_name
hls.mydressin-server.com
;
return
301
https://
$server_name$request_uri
;
}
server
{
listen
443
ssl
;
server_name
status.mydressin-server.com
;
ssl_certificate
/usr/local/nginx/conf/ssl/PositiveSSL_Wildcard_mydressin-server.com.pem
;
ssl_certificate_key
/usr/local/nginx/conf/ssl/PositiveSSL_Wildcard_mydressin-server.com.pem
;
location
/
{
proxy_pass
http://localhost:3003
;
proxy_set_header
Host
$host
;
proxy_set_header
X-Real-IP
$remote_addr
;
proxy_set_header
X-Forwarded-For
$proxy_add_x_forwarded_for
;
proxy_set_header
X-Forwarded-Proto
$scheme
;
}
}
server
{
listen
80
;
server_name
status.mydressin-server.com
;
return
301
https://
$server_name$request_uri
;
}
}
This diff is collapsed.
Click to expand it.
register-live-api/recorder.js
+
1
−
1
Voir le fichier @
fc696f4d
...
...
@@ -163,4 +163,4 @@ async function getViewerCount(streamKey) {
}
}
module
.
exports
=
{
startRecording
,
stopRecording
,
getViewerCount
}
module
.
exports
=
{
startRecording
,
stopRecording
,
getViewerCount
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
setup.sh
0 → 100755
+
203
−
0
Voir le fichier @
fc696f4d
#!/bin/bash
# Set up error handling
set
-e
# Update the package list and install required dependencies
sudo
apt update
# Install build dependencies for nginx and nginx-rtmp-module
sudo
apt
install
-y
build-essential git zlib1g-dev libpcre3 libpcre3-dev libssl-dev ffmpeg nodejs npm openssl
# Directory to store the build files
BUILD_DIR
=
"/tmp/nginx-rtmp-build"
# Create the build directory
mkdir
-p
"
$BUILD_DIR
"
cd
"
$BUILD_DIR
"
# Clone the necessary repositories
git clone https://github.com/arut/nginx-rtmp-module.git
git clone https://github.com/nginx/nginx.git
# Build nginx with the RTMP module
cd
nginx
./auto/configure
--add-module
=
../nginx-rtmp-module
--with-http_ssl_module
make
sudo
make
install
# Install nginx modules (pcre, etc.) and create necessary directories
sudo mkdir
-p
/usr/local/nginx/html
sudo mkdir
-p
/usr/local/nginx/conf/ssl
sudo mkdir
-p
/tmp/hls
sudo mkdir
-p
/tmp/dash
# SSL Setup: Copy SSL certificates to nginx SSL directory (replace with your actual certificate path)
sudo cp
./PositiveSSL_Wildcard_mydressin-server.com.pem /usr/local/nginx/conf/ssl/
# Configure optimized nginx.conf
sudo
bash
-c
"cat > /usr/local/nginx/conf/nginx.conf"
<<
'
EOF
'
daemon off;
error_log /dev/stdout info;
events {
worker_connections 8192;
use epoll;
multi_accept on;
}
rtmp {
server {
listen 1935;
chunk_size 4096;
application live {
live on;
record off;
# HLS settings
hls on;
hls_path /tmp/hls;
hls_fragment 3s;
hls_playlist_length 18s;
hls_fragment_naming system;
hls_fragment_naming_granularity 2;
hls_fragment_slicing aligned;
# HLS bitrate variants
hls_variant _low BANDWIDTH=800000;
hls_variant _mid BANDWIDTH=1200000;
hls_variant _high BANDWIDTH=2400000;
# DASH settings
dash on;
dash_path /tmp/dash;
dash_fragment 3s;
dash_playlist_length 18s;
# Reduce CPU usage
meta copy;
}
}
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
open_file_cache max=1000 inactive=20s;
open_file_cache_valid 30s;
open_file_cache_min_uses 2;
open_file_cache_errors on;
gzip on;
gzip_comp_level 5;
gzip_min_length 256;
gzip_proxied any;
gzip_vary on;
gzip_types
application/atom+xml
application/javascript
application/json
application/ld+json
application/manifest+json
application/rss+xml
application/vnd.geo+json
application/vnd.ms-fontobject
application/x-font-ttf
application/x-web-app-manifest+json
application/xhtml+xml
application/xml
font/opentype
image/bmp
image/svg+xml
image/x-icon
text/cache-manifest
text/css
text/plain
text/vcard
text/vnd.rim.location.xloc
text/vtt
text/x-component
text/x-cross-domain-policy;
server {
listen 443 ssl;
server_name hls.mydressin-server.com;
ssl_certificate /usr/local/nginx/conf/ssl/PositiveSSL_Wildcard_mydressin-server.com.pem;
ssl_certificate_key /usr/local/nginx/conf/ssl/PositiveSSL_Wildcard_mydressin-server.com.pem;
location /hls {
types {
application/vnd.apple.mpegurl m3u8;
}
root /tmp;
add_header Cache-Control no-cache;
add_header Access-Control-Allow-Origin *;
expires -1;
}
location /stat {
rtmp_stat all;
rtmp_stat_stylesheet stat.xsl;
}
location /stat.xsl {
root /usr/local/nginx/html;
}
location /control {
rtmp_control all;
add_header Access-Control-Allow-Origin * always;
}
location / {
root html;
index index.html index.htm;
}
}
server {
listen 80;
server_name hls.mydressin-server.com;
return 301 https://
$server_name$request_uri
;
}
}
EOF
# Expose necessary ports (80 for HTTP, 443 for HTTPS, and 1935 for RTMP)
sudo
ufw allow 80
sudo
ufw allow 443
sudo
ufw allow 1935
# Setup Node.js app
# Install npm packages and PM2 (Process Manager for Node.js)
sudo
npm
install
sudo
npm
install
pm2
-g
# Expose Node.js port (3003)
sudo
ufw allow 3003
sudo chmod
+x ./start.sh
# Make the script executable
# Start Nginx and Node.js app
sudo
./start.sh
# Clean up the build directory
echo
"Setup complete. Nginx with RTMP, SSL, and Node.js are running."
This diff is collapsed.
Click to expand it.
start.sh
+
1
−
1
Voir le fichier @
fc696f4d
...
...
@@ -4,5 +4,5 @@
/usr/local/nginx/sbin/nginx &
# Start the Node.js app
node
/
ap
p
/server.js
node
./register-live-
ap
i
/server.js
This diff is collapsed.
Click to expand it.
Aperçu
0%
Veuillez réessayer
ou
joindre un nouveau fichier
.
Annuler
You are about to add
0
people
to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Enregistrer le commentaire
Annuler
Veuillez vous
inscrire
ou vous
se connecter
pour commenter