I'm experiencing issues with setting up HLS streaming using Nginx. I have configured my Nginx server to serve HLS content, but I keep encountering a "404 (Not Found)" error when trying to access the stream.m3u8 file. Below is the configuration of my Nginx server and the site-available configuration file:
Nginx Configuration (nginx.conf):
`worker_processes auto;
events {
worker_connections 1024;
}
# RTMP configuration
rtmp {
server {
listen 1935; # Listen on standard RTMP port
chunk_size 4000;
application show {
live on;
# Turn on HLS
hls on;
hls_path /nginx/hls/;
hls_fragment 3;
hls_playlist_length 60;
# disable consuming the stream from nginx as rtmp
deny play all;
}
}
}
http {
sendfile off;
tcp_nopush on;
aio on;
directio 512;
default_type application/octet-stream;
server {
listen 8080;
location / {
# 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;
}
root /nginx/;
}
}
}`
site-available Configuration (transmision.omnivision.com.sv):
server {
root /var/www/transmision;
index index.html index.htm index.nginx-debian.html;
server_name transmision.omnivision.com.sv;
location / {
try_files $uri $uri/ =404;
}
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/transmision.omnivision.com.sv/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/transmision.omnivision.com.sv/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
if ($host = transmision.omnivision.com.sv) {
return 301 https://$host$request_uri;
} # managed by Certbot
server_name transmision.omnivision.com.sv;
listen 80;
return 404; # managed by Certbot
}
Despite configuring Nginx to serve HLS content, I'm unable to access the stream.m3u8 file and consistently receive a "404 (Not Found)" error. Can anyone help me troubleshoot and resolve this issue? Any assistance would be greatly appreciated. Thanks!
I configured my Nginx server following the guidelines to enable HLS streaming. I expected that upon accessing the stream.m3u8 file, it would play smoothly in the corresponding media player. However, instead of that, I received a "404 (Not Found)" error when trying to access the file.
Steps followed:
- Configured the Nginx server to enable HLS streaming using the HLS module.
- Verified that the HLS files were generated correctly in the specified directory.
- Tested playback of the stream.m3u8 file using various media players such as VLC and web players compatible with HLS.
- Checked the permissions of files and directories related to HLS streaming to ensure they were accessible by the Nginx server.
- Reviewed Nginx error logs for clues about the cause of the 404 error.
Expected outcome: I expected that upon accessing the stream.m3u8 file, it would load successfully and start playing the video without issues.
Actual outcome: However, upon trying to access the stream.m3u8 file, I received a "404 (Not Found)" error, which prevented video playback.
I hope this helps for sharing on Stack Overflow.