Score:0

What is the correct nginx configuration to proxy_pass to a local VLC video stream?

np flag

I want to be able to forward my IP Camera's feed to a website. I want to make my website public via my nginx server (on Ubuntu 20.04).

First of all, I use VLC to re-stream my IP cameras feed:

vlc --intf dummy -vvv "rtsp://<user>:<password>@10.0.0.34:554/stream2" --sout "#transcode{vcodec=theo,vb=720,scale=Auto,acodec=none,ab=128,channels=2,samplerate=44100,scodec=none}:http{mux=ogg,dst=:8081/}" --sout-all --sout-keep --nooverlay --daemon

That means that I locally, on my LAN, can do something like this

<html>
    <head>/head>
    <body>

        <video>
          <source src="http://10.0.0.63:8080" type="video/mp4">
        </video>

    </body>
</html>

Allright, it works locally, but how can I configure my nginx server to pass the feed?

This is what I want to achieve: https://my.domain.com/camera2 --nginx-server--> http://10.0.0.63:8080

<html>
    <head>/head>
    <body>

        <video>
          <source src="https://my.domain.com/camera2" type="video/mp4">
        </video>

    </body>
</html>

This is what I have tried with no success:

http {
    proxy_cache_path  /var/www/my.domain.com/cache  levels=1:2    keys_zone=STATIC:10m  inactive=24h  max_size=1g;
    server {
            listen          80;
            server_name     my.domain.com;

            location /camera2 {
                    proxy_pass      http://10.0.0.63:8080;
                    proxy_http_version 1.1;
                    proxy_set_header Upgrade $http_upgrade;
                    proxy_set_header Connection 'upgrade';
                    proxy_set_header Host $host;
                    proxy_cache_bypass $http_upgrade;
            }
    }
}

nginx.conf

What is the correct nginx configuration to proxy_pass to a local VLC video stream?

Score:1
gu flag

Most likely you just need to rewrite the path to avoid querying http://10.0.0.63:8080/camera2 but instead query http://10.0.0.63:8080/.

I don't know much about how VLC concerts RTSP to HTTP though so it might be something else entirely.

np flag
Actually I have many cameras, handled by different VLC instances on my Ubuntu server. I.e.: http://10.0.0.63:8080/ -camera2; http://10.0.0.63:8081/ -camera3; http://10.0.0.63:8082/ -camera4; (etc.) Maybe I do not understand you, but how can I get the feed from outside? Like in https://my.domain.com/camera2 (etc.)
Ginnungagap avatar
gu flag
I get you want the public URL for a camera to be `/cameraX`, but the current configuration forwards that URL to VLC. Try using `proxy_pass http://10.0.0.63:8080/;` instead to strip the `/cameraX` part when sending the request to VLC.
np flag
I'm not sure I get the point? :-) Can't you provide a dummy configuration in your answer? If it works, I will mark it as the correct answer.
np flag
Now I understood! The trailing `/` did the trick! Thank you very much!
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.