Not Sure How To Articulate This Problem

So, I am working on a program that requires incoming http and rtmp to the server to be processed by LXD containers on the same server. I can forward the incoming rtmp to the correct container where the rtmp segments are being stored as .ts segments and the m3u8 file. HAproxy handles this fine.

My problem is the getting the stream ID play. This is done by http and works fine without using containers.
However does not work from the container.

The following network screen grab are for the working case that is not using containers. Can this be duplicated using haproxy in the case of using containers to store the video and play it?


Is there other information you need to answer this, please let me know.

Thanks,

Ray

Here is the current haproxy.cfg I am using to forward the rtmp requests. I have redacted the host IP for obvious reasons. Note that I can ping out from the containers to the host as well as to the internet (yahoo, google, etc).

This is clearly not the entire configuration, as you also need the TCP port 3000 forwarding, right?

Please share the entire configuration and logs.

So, I have a REACT application video player on the host that uses port 3000. But now I am wondering if I should create another container and install the player there?

image

The Media Server appears to be working properly as I can see the live video segments being created. The broadcaster points his rtmp to the host server, for example rtmp://”host IP”:1935/container1 and is forwarded via host HAproxy to container1, port 1935 where the media server is listening.

I can create an MP4 from the .ts segments that the media server creates, using ffmpeg which pretty much proves the front end of this process is working.

However I need to be able to view the video from the internet to confirm things are working from beginning to end, end being viewing the broadcast from the internet.

My next experiment will be to use iptables in the host to port-forward incoming http://server IP/container1 on port 80 to the HAPROXY container where HAproxy will then forward the request to either the video player on the host, or the player in it’s own container?

I don’t know if having the video player in its own container buys me anything?

Note that I am doing this locally. This configuration is for testing only. Eventually I will be using CDN to distribute the live stream.

So disclaimer, I am not a programmer at all. I am technical savvy and just trying to get an idea to work.

Does all this make sense?

Ray

Forgot to include that I am running nginx. I have not touched the nginx configuration.

So the broadcast viewer would browse to http://“server IP”/LPC1 for example.
The server has HAproxy running and should forward this http to the container Player. I know very little about HAproxy so you help would be much appreciated.

Here is the HAconfig I am trying:

frontend http-in
mode http
bind localhost:80
reqadd X-Forwarded-Pronto:\ http
# default_backend app
# Incoming LPC http request
acl is_LPC path_beg /LPC1
use_backend LPC1 if is_LPC

backend LPC1
mode http
option forwardfor
no option httpclose
option http-server-close
option forceclose
server Player 10.106.37.166:3000/embed/0x35e01199F8137077346FDD476191f1967A52BDb5 check

And here is the error I am getting:

Aug 15 22:58:19 localhost haproxy[25453]: [ALERT] 226/185819 (25453) : Starting frontend http-in: cannot bind socket [::1:80]

Thanks for your help.

Ray

Remove the localhost from your bind line, it only causes a mess with IPv6. bind :80 shoud be fine.

I’m afraid that I can’t help you with your video delivery and container questions, I can only help with actual haproxy configuration.

So when I changed nginx to port 81 I now get 404 Not Found.

Question: Does the http://”serverIP”/LPC1 query happen before the HAproxy is triggered ? I keep getting 404 Not Found.

I simply want HAproxy to forward based on what follows the “/”. There is no .html. I then want the Player to trigger. Make sense?

Here is the HAproxy config:

frontend http-in

    mode http

    bind xx.xxx.31.177:81

    #bind localhost:81

    reqadd X-Forwarded-Pronto:\ http

    # default_backend app

    # Incoming LPC http request

    acl is_LPC path_beg /LPC1

    use_backend LPC1 if is_LPC

    acl is_LPC path_beg /LPC2

    use_backend LPC2 if is_LPC

backend LPC1

    mode http

    option forwardfor

    no option httpclose

    option http-server-close

    option forceclose

    server Player 10.106.37.166:3000/embed/0x35e01199F8137077346FDD476191f1967A52BDb5  check

backend LPC2

    mode http

    option forwardfor

    no option httpclose

    option http-server-close

    option forceclose

    server Player 10.106.37.166:3000/embed/0x45e0111238137077346FDD476191f1967A52AC23  check

Thanks,

Ray

This is not a valid configuration. You don’t specify the URI or parts of it here. After the port number there must come a space with additional keywords, like check, or end of line.

404 not found is generated by the backend server, haproxy never generates this error.

Thanks Lucas for your help with this.

So how do I include that information after the port #? It is vital to what I am trying to achieve.

Ray

You don’t have to do anything. What the client requests is passed transparently to the backend.