Skip to content

Commit

Permalink
NGINX: Support set the m3u8 and ts expire. v5.14.3
Browse files Browse the repository at this point in the history
  • Loading branch information
winlinvip committed Mar 1, 2024
1 parent 59e12fa commit c7c2805
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/nginx-hls-cdn.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
run: |
SRS_MAJOR_HTTP=nginx-hls-cdn-http
SRS_MAJOR_HTTPS=nginx-hls-cdn-https
SRS_VERSION=v1.0.1
SRS_VERSION=v1.0.2
echo "SRS_MAJOR_HTTP=$SRS_MAJOR_HTTP" >> $GITHUB_ENV
echo "SRS_MAJOR_HTTPS=$SRS_MAJOR_HTTPS" >> $GITHUB_ENV
echo "SRS_VERSION=$SRS_VERSION" >> $GITHUB_ENV
Expand Down
1 change: 1 addition & 0 deletions DEVELOPER.md
Original file line number Diff line number Diff line change
Expand Up @@ -1140,6 +1140,7 @@ The following are the update records for the SRS Stack server.
* Dubbing: Support VoD dubbing for multiple languages. v5.14.2
* Dubbing: Support disable translation, rephrase, or tts. v5.14.3
* Dubbing: Highlight the currently playing group. v5.14.3
* NGINX: Support set the m3u8 and ts expire. v5.14.3
* v5.13:
* Fix bug for vlive and transcript. v5.13.1
* Support AWS Lightsail install script. v5.13.2
Expand Down
3 changes: 2 additions & 1 deletion scripts/nginx-hls-cdn/Dockerfile.http
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ ARG ARCH
FROM ${ARCH}nginx:latest AS dist

# The environment variables for template.
ENV SRS_STACK_SERVER=127.0.0.1:2022
ENV SRS_STACK_SERVER=127.0.0.1:2022 \
SRS_M3U8_EXPIRE=10 SRS_TS_EXPIRE=3600
ADD nginx.edge.http.conf.template /etc/nginx/templates/default.conf.template

# Create the proxy cache directory for NGINX.
Expand Down
3 changes: 2 additions & 1 deletion scripts/nginx-hls-cdn/Dockerfile.https
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ FROM ${ARCH}nginx:latest AS dist
# The environment variables for template.
ENV SRS_STACK_SERVER=127.0.0.1:2022 \
SRS_STACK_SSL_KEY=/data/config/nginx.key \
SRS_STACK_SSL_CRT=/data/config/nginx.crt
SRS_STACK_SSL_CRT=/data/config/nginx.crt \
SRS_M3U8_EXPIRE=10 SRS_TS_EXPIRE=3600
ADD nginx.edge.https.conf.template /etc/nginx/templates/default.conf.template

# Create the proxy cache directory for NGINX.
Expand Down
6 changes: 5 additions & 1 deletion scripts/nginx-hls-cdn/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,11 @@ docker run --rm -it --name srs-stack-nginx01 -d \
ossrs/srs-stack:nginx-hls-cdn-https
```

> Note: Please replace the IP `128.199.114.145` with your SRS Stack.
> Note: Please set the `SRS_STACK_SERVER` by replacing the IP `128.199.114.145` with your SRS Stack.
> Note: Set the `SRS_M3U8_EXPIRE` to your SRS `hls_fragment` which is the TS duration, or the expired time to refresh the m3u8. Default value is 10 seconds.
> Note: Set the `SRS_TS_EXPIRE` for the expired time for TS file. Default value is 3600 seconds.
A HTTPS HLS stream should be available at [https://nginx01.your-domain.com/live/livestream.m3u8](http://128.199.114.145:2022/tools/player.html?url=https://nginx01.your-domain.com/live/livestream.m3u8),
and now you got an Nginx server that supports HLS stream over HTTPS.
Expand Down
6 changes: 3 additions & 3 deletions scripts/nginx-hls-cdn/nginx.edge.http.conf.template
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ server {
listen 80 default_server;
listen [::]:80 default_server;

proxy_cache_valid 404 10s;
proxy_cache_valid 404 10s;
proxy_cache_lock on;
proxy_cache_lock_age 300s;
proxy_cache_lock_timeout 300s;
Expand All @@ -18,7 +18,7 @@ server {

proxy_cache srs_cache;
proxy_cache_key $scheme$proxy_host$uri$args;
proxy_cache_valid 200 302 10s;
proxy_cache_valid 200 302 ${SRS_M3U8_EXPIRE}s;
add_header X-Cache-Status $upstream_cache_status;
}

Expand All @@ -28,7 +28,7 @@ server {

proxy_cache srs_cache;
proxy_cache_key $scheme$proxy_host$uri;
proxy_cache_valid 200 302 60m;
proxy_cache_valid 200 302 ${SRS_TS_EXPIRE}s;
add_header X-Cache-Status $upstream_cache_status;
}
}
6 changes: 3 additions & 3 deletions scripts/nginx-hls-cdn/nginx.edge.https.conf.template
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ server {
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;

proxy_cache_valid 404 10s;
proxy_cache_valid 404 10s;
proxy_cache_lock on;
proxy_cache_lock_age 300s;
proxy_cache_lock_timeout 300s;
Expand All @@ -27,7 +27,7 @@ server {

proxy_cache srs_cache;
proxy_cache_key $scheme$proxy_host$uri$args;
proxy_cache_valid 200 302 10s;
proxy_cache_valid 200 302 ${SRS_M3U8_EXPIRE}s;
add_header X-Cache-Status $upstream_cache_status;
}

Expand All @@ -37,7 +37,7 @@ server {

proxy_cache srs_cache;
proxy_cache_key $scheme$proxy_host$uri;
proxy_cache_valid 200 302 60m;
proxy_cache_valid 200 302 ${SRS_TS_EXPIRE}s;
add_header X-Cache-Status $upstream_cache_status;
}
}

0 comments on commit c7c2805

Please sign in to comment.