当尝试查看从OBS发送到Nginx的HLS流时,我不断收到错误消息:
33 open() "/usr/share/nginx/html/HLS/live/5cc56be78cea0.m3u8" failed (2: No such file or directory)
但是路径/usr/share/nginx/html/HLS/live/
存在(还创建了流文件),我再次检查了文件夹权限
我的Nginx配置服务器块是:
server {
listen 444 ssl;
listen [::]:444 ssl;
ssl_certificate /etc/ssl/certs/concartcert.crt;
ssl_certificate_key /etc/ssl/private/nginx-selfsigned.key;
server_name 129.567.55.36;
location /live {
# 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/vnd.apple.mpegurl m3u8;
}
alias /usr/share/nginx/html/HLS/live;
}
# allows us to see how stats on viewers on our Nginx site using a URL like: "http://my-ip/stats"
# location /stats {
# stub_status;
# }
location /stat {
rtmp_stat all;
rtmp_stat_stylesheet stat.xsl;
}
location /stat.xsl {
root html;
}
location /control {
rtmp_control all;
}
# allows us to host some webpages which can show our videos: "http://my-ip/my-page.html"
location / {
root html;
index index.html index.htm;
}
}
谁能帮助我确定错误的可能原因。在线检查时,确定的两个可能原因是文件夹权限或文件夹路径,但是在检查了两者之后,我迷失了如何进行操作。
答案 0 :(得分:0)
我将在服务器块中而不是位置块中使用root,然后在位置块中使用try_files,如下所示:
server {
listen 444 ssl;
listen [::]:444 ssl;
ssl_certificate /etc/ssl/certs/concartcert.crt;
ssl_certificate_key /etc/ssl/private/nginx-selfsigned.key;
server_name 129.567.55.36;
root /usr/share/nginx/html;
index index.html index.htm;
location /live {
# 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/vnd.apple.mpegurl m3u8;
}
try_files /HLS/live/$uri =404
}
#allows us to see how stats on viewers on our Nginx site using a URL like: "http://my-ip/stats"
#location /stats {
# stub_status;
#}
location /stat {
rtmp_stat all;
rtmp_stat_stylesheet stat.xsl;
}
location /control {
rtmp_control all;
}
#allows us to host some webpages which can show our videos: "http://my-ip/my-page.html"
location / {
try_files $uri $uri/ =404;
}
}
如果/ stat和/ control URL由于具有另一个根路径而不再起作用,则应在这些位置块中使用alias
和完整路径。