Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HLS: How to use NGINX to setup a HLS delivery cluster. #2989

Closed
winlinvip opened this issue Mar 31, 2022 · 2 comments
Closed

HLS: How to use NGINX to setup a HLS delivery cluster. #2989

winlinvip opened this issue Mar 31, 2022 · 2 comments
Assignees
Labels
Discussion Discussion or questions. EnglishNative This issue is conveyed exclusively in English.
Milestone

Comments

@winlinvip
Copy link
Member

winlinvip commented Mar 31, 2022

It works like this:

FFmpeg/OBS ---RTMP--> SRS Origin Server ---HLS--> NGINX Servers --> Players of Visitors

SRS is serve as an Origin server, to covert RTMP to HLS, and feed all NGINX Servers.

There are many NGINX Servers, to serve a set of Players. For example, if we got 10 NGINX Servers, each bandwidth is 5Gbps, then we can serve 50Gbps streams. That is, if each stream is 1Mbps, we could serve about 50k visitors.

Please read wiki:

@winlinvip
Copy link
Member Author

winlinvip commented Apr 4, 2022

Nginx Cache Control

If ignore the cache control header, NGINX won't follow the upstream, literally should NOT set it:

proxy_ignore_headers Cache-Control Expires;

By default, Nginx uses cache-control to overwrite the proxy_cache_valid, please read this post.

So, we should set the cache-control by upstream server, SRS or NGINX:

# For HLS delivery
location ~ /.+/.*\.(m3u8)$ {
  root /usr/local/lighthouse/softwares/srs-terraform/mgmt/containers/objs/nginx/html;
  add_header Cache-Control "public, max-age=10";
}
location ~ /.+/.*\.(ts)$ {
  root /usr/local/lighthouse/softwares/srs-terraform/mgmt/containers/objs/nginx/html;
  add_header Cache-Control "public, max-age=86400";
}

Note that SRS does not set the Cache-Control, see #2991

@winlinvip
Copy link
Member Author

Fixed.

@winlinvip winlinvip added the EnglishNative This issue is conveyed exclusively in English. label Jul 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Discussion Discussion or questions. EnglishNative This issue is conveyed exclusively in English.
Projects
None yet
Development

No branches or pull requests

1 participant