php - Nginx "No such file or directory error" for existing file path with appropriate permissions
When attempting to view the HLS stream being sent from OBS to Nginx, I keep getting the error:
33 open() "/usr/share/nginx/html/HLS/live/5cc56be78cea0.m3u8" failed (2: No such file or directory)
but the path/usr/share/nginx/html/HLS/live/
DOES exist (the stream file is also created) and I double checked the folder permissions
My Nginx config server block is:
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;
}
}
Could anyone help my identify the possible cause of the error. Checking online, the two possible causes identified were the folder permissions or the folder path but after checking both I am lost on how to proceed.
Answer
Solution:
I would use root in the server block instead of in the location blocks and then a try_files in the location blocks, like this:
If the /stat and /control URLs don't work anymore because they have another root path, you should use
alias
with the full path in those location blocks.