You can use NGINX as a proxy/cache for HLS streams generated by Oryx.
Development
Build the NGINX HLS CDN image using:
docker build -t ossrs/oryx:nginx-hls-cdn scripts/nginx-hls-cdn
Running as a Proxy
To run NGINX as a proxy in Docker, pass the ORYX_SERVER environment variable pointing to your Oryx instance:
ORYX_SERVER=$(ifconfig en0 | grep 'inet ' | awk '{print $2}')
docker run --rm -it -p 80:80 --name nginx -e ORYX_SERVER=${ORYX_SERVER}:2022 ossrs/oryx:nginx-hls-cdn
Production Setup
To set up a production HLS Edge server:
- Install Oryx (via BT, aaPanel, or Docker).
- Create a new WebSite in your web server (e.g., Nginx) to proxy requests to the NGINX HLS Edge server.
- Use the following Nginx configuration for the proxy site:
location /tools/ {
proxy_pass http://localhost:2022;
}
location / {
proxy_no_cache 1;
proxy_cache_bypass 1;
add_header X-Cache-Status-Proxy $upstream_cache_status;
proxy_pass http://localhost:23080;
}
- Start the NGINX HLS Edge server container, mapping port 80 to 23080:
docker run --rm -it -e ORYX_SERVER=$PIP:2022 -p 23080:80 --name oryx-nginx01 -d ossrs/oryx:nginx-hls-cdn
Important Note on CORS: The NGINX cache stores CORS headers. If a request is cached without CORS headers, subsequent requests with an Origin header that requires CORS will still receive the cached version without CORS.