# 创建 rtmp 配置文件
cat > /www/server/nginx/conf/rtmp.conf << 'EOF'
rtmp {
server {
listen 1935;
application live {
live on;
record off;
# HLS 配置
hls on;
hls_path /www/streaming/hls-data;
hls_fragment 3s;
hls_playlist_length 60s;
hls_nested on;
# 访问控制(可选)
allow publish all;
allow play all;
}
}
}
EOF
# 在主配置文件中引入 rtmp 配置
echo 'include rtmp.conf;' >> /www/server/nginx/conf/nginx.conf
# 修改网站配置文件
cat > /www/server/panel/vhost/nginx/stream.hls.henandafang.com.conf << 'EOF'
server {
listen 80;
server_name stream.hls.henandafang.com;
root /www/streaming/www;
index index.php index.html;
# HLS 流访问
location /hls {
alias /www/streaming/hls-data;
add_header Cache-Control no-cache;
add_header Access-Control-Allow-Origin *;
types {
application/vnd.apple.mpegurl m3u8;
video/mp2t ts;
}
}
# PHP 支持
location ~ \.php$ {
fastcgi_pass unix:/tmp/php-cgi-81.sock;
fastcgi_index index.php;
include fastcgi.conf;
}
# 静态文件
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ {
expires 30d;
}
location ~ .*\.(js|css)?$ {
expires 12h;
}
}
EOF
# 重启 Nginx
service nginx restart temp
文章如无特别注明均为原创!
作者:
等风也等你,
转载或复制请以
超链接形式 并注明出处 走近风的BLOG。
原文地址《
temp》发布于2025年12月19日
点滴生活,生活点滴,都需要你来陪伴,往后余生,请多多指教。男人最幸福的事情是:一个好妻子,一份好工作,一个好身体。