warren-bank / HLS-Proxy

Node.js server to proxy HLS video streams
http://webcast-reloaded.surge.sh/proxy.html
GNU General Public License v2.0
244 stars 75 forks source link

Proxy configured to be on a domain, the port blocks further requests #11

Open alekorhonen opened 2 years ago

alekorhonen commented 2 years ago

I've setup the proxy to run on port 8080 and the host is targeted at a subdomain.

I can nicely load the manifest file, but every url that it points to after that includes the port in the URL. So instead of proxy.mydomain.com it becomes proxy.mydomain.com:8080 which is an invalid request.

I did a really dirty workaround for now, which was that I modified the host value in start_http.js just to replace the :8080 out of there.

warren-bank commented 2 years ago

Hi. I don't understand your situation.

Are you running the proxy at: http://proxy.mydomain.com:8080?

What are some example URLs for:

What are the encoded URLs (directed through proxy) for each example? How are they incorrect for your situation?

The fact that the proxy encodes the URLs it finds within manifests is intended to redirect those URLs through the proxy, which (in your example) is listening at port 8080. To remove this port would make the URLs default to port 80.. which wouldn't reach the proxy; you may have another httpd listening on 80, but it wouldn't understand the base64 encoded URL path.

alekorhonen commented 2 years ago

Yes, I am running the proxy at http://proxy.mydomain.com:8080. I have a reverse proxy setup for the subdomain through nginx that points to that port (8080) so that I can setup authentication layer on top of the hls proxy, if that makes sense.

Now the master manifest loads fine when I request it, but all the urls contained in the master manifest include the port in the url, which is what I do not want in there because the url's are invalid in my case and will not point anywhere.

Let's say we load the master manifest at first http://proxy.mydomain.com/<BASE64>.m3u8

After loading the master manifest, all the url's in there point to http://proxy.mydomain.com:8080/ instead of http://proxy.mydomain.com/.

warren-bank commented 2 years ago

now, my understanding is that..

the public facing server is located at:

and you've configured this server (after proper authentication) to reverse proxy (conceptually similar to a URL redirect) all requests for all paths to:

This code is relevant to your situation. The code comments speak to your exact situation, which probably never bubbled up to become visible in the README. The solution is that when you start the proxy server on the command-line, you embed the public facing port number in the host option. For example, --host "proxy.mydomain.com:80" --port 8080

Please give this a try, and let me know if it solves your situation. Thanks.