0

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?

Hauns TM
  • 117
  • 2
  • 2
  • 9

1 Answers1

1

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.

Ginnungagap
  • 2,595
  • 10
  • 13
  • 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.) – Hauns TM Jan 12 '22 at 06:17
  • 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. – Ginnungagap Jan 12 '22 at 07:42
  • 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. – Hauns TM Jan 12 '22 at 15:35
  • Now I understood! The trailing `/` did the trick! Thank you very much! – Hauns TM Jan 12 '22 at 20:48