blakeblackshear / frigate

NVR with realtime local object detection for IP cameras
https://frigate.video
MIT License
18.11k stars 1.65k forks source link

IPv6 Support #5275

Closed Sammy1Am closed 1 year ago

Sammy1Am commented 1 year ago

Describe what you are trying to accomplish and why in non technical terms I would like to be able to connect to Frigate using the IPv6 address assigned to its docker container; I'm working on moving all my dockers to IPv6-only (largely as an experiment toward moving to a primarily IPv6-stack on my home LAN), but I'm generally finding that IPv6 has a lot of advantages and I'm trying to use it more.

Describe the solution you'd like IPv6 connections would be possible either out-of-the-box or with some configuration.

Describe alternatives you've considered I have this working currently by bind-mounting my own local nginx.conf over Frigate's /usr/local/nginx/conf/nginx.conf, and replacing the line listen 5000; with listen [::]:5000;. However this means any upstream updates to nginx.conf won't show up in my docker.

Additional context

It's also possible I've missed something somewhere else that would enable IPv6 in a more user-configurable way, so I'm happy to be pointed in the right direction there too.

NickM-27 commented 1 year ago

Looks similar to: https://github.com/blakeblackshear/frigate/pull/3497

I'd make a similar request to go2rtc as I imagine it will need to have its own support added or at least docs put up about it

Sammy1Am commented 1 year ago

It does indeed look similar to that one, though based on my (light) testing, just replacing that line means IPv4 doesn't work anymore. You'd need to have both listen 5000 and listen [::]:5000 for nginx to respond on both.

Actually, it looks like the ideal solution may be replacing the line with listen [::]:5000 ipv6only=off; which allows nginx to respond to both IPv4 and IPv6, and doesn't seem to make go2rtc as cranky about origins (or at least doesn't here on my dual stack network, I don't really have the ability at the moment to test this on an IPv4-only network/docker).

As far as go2rtc, I actually think it's working okay already. I was able to use this on my camera and it seems fine:

inputs:
        - path: rtsp://[::1]:8554/frontdoor?video=h264
          input_args: preset-rtsp-restream
          roles:
            - detect
        - path: rtsp://[::1]:8554/frontdoor
          input_args: preset-rtsp-restream
          roles:
            - record

And MSE and WebRTC are both still working okay in my browser (with ipv6only=off or ipv6only=on for nginx). Though since nearly everything is wrapped by nginx's port 5000, it's maybe less important that IPv4 stuff is happening within the container (i.e. when 127.0.0.1 connections are made to various things).

Edit: Just double-checked, and it seems like golang just listens to IPv4 and IPv6 by default, so go2rtc should likely be fine.

github-actions[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

imp1sh commented 8 months ago

How to enable IPv6 for the container? I can't find a solution.

Sammy1Am commented 8 months ago

The solution that worked for me was to use my own nginx.conf file and replace listen 5000; with listen [::]:5000 ipv6only=off;. This enables IPv6 for nginx, which is wrapping Frigate.

Your Docker stack will also need IPv6 enabled, but that's not a question for here.

imp1sh commented 8 months ago

Having to manage my own nginx is only a workaround, no solution. It should be configurable either via environment variables or just have better default values like below.

I believe this is best practice in Nginx if you'd like to run dual stack. If I'm not fully mistaken this should also be done for rtmp.

listen 5000;
listen [::]:5000;
[...]
listen 1935;
listen[::]:1935;