Docker automatically allocated IPs getting messed up?

This is a bit of a puzzler, but maybe other people have also experienced it:

In configuration.yaml months ago when the reverse proxy trust warning first started to appear, I did this:

http:
  use_x_forwarded_for: true
  trusted_proxies:
    - 172.30.33.11

This works fine, but when I restart the whole machine, the damn reverse proxy (I use the Nginx Proxy Manager addon) gets a different Docker IP!

Thus, I lose remote connection, have to change this entry to the new IP and, in by far the most annoying development, today the Docker IP that Nginx got allocated was my DeConz addon IP!

Thus, it messed up the connection with the DeConz integration and since I can’t find a way to set static IPs for either the DeConz addon or the Nginx addon, I had to reinstall the DeConz integration & had some Zigbee entities renamed in the process.

So, my question is, how can I prevent the Nginx addon (but really any addon, if possible) to get allocated whatever random Docker IP at restart? Or, if this is not possible, how can I change its IP so that I don’t have to go around reconfiguring other things or clash with DeConz like today? Can Portainer do that?

For reverse proxy, you can just use-

http:
  use_x_forwarded_for: true
  trusted_proxies:
    - 172.30.33.0/24

Thus, whenever the Nginx server proxy changes, it is still accepted.

1 Like

Thanks for that! I’ll change the config now.

But what do I do if it once again takes over some other addon’s Docker IP? This really seems like a terrible bug to have :frowning:

For the reverse proxy, it does not matter if the proxy server IP changes because you are using 172.30.33.0/24.

Yeah, it definitely solves my problem with the reverse proxy, but as I saw this morning, the reverse proxy can still be allocated an IP which clashes with another addon (DeConz in this case), so how would I go about solving that?

There shouldn’t be any “clash” unless you assigned a static IP to one of the addons.
Did you? If you did, don’t :wink:

You can always use the container name as the hostname rather than use the IP.

1 Like

Well, the DeConz integration makes me select a DeConz addon IP when setting it up, you reckon I could actually just use a container name in there?

As in, “addon_core_deconz” instead of its IP? That would be great, had no idea it was possible, could you just please confirm that it should be possible before I reinstall the integration again? :smiley:

If addon_core_deconz is the container name as seen in a docker ps or portainer, then yes.
To confirm, just ssh into HA (via the SSH addon + login), and do a ping addon_core_deconz

The ping command returns a “bad address addon_core_deconz”, but docker ps looks like this, which seems OK:

  • Host: core-deconz
  • (API) Port: 40850
  • WebSocket Port: 8081

From:

https://github.com/home-assistant/addons/blob/13d6f2484bf37d440ecdf9057fe4cfb94af028de/deconz/DOCS.md#using-the-deconzphoscon-api-with-another-add-on

Right above that, though, it says: “WARNING Do not use the following settings to set up a integration manually from within Home Assistant!” :smiley:

You are not setting up an integration you are setting up the nginx addon. Or have I misunderstood your issue?

I had 2 issues:

  1. The nginx proxy manager addon would change its Docker IP upon restart and make me edit its whitelisted IP in configuration.yaml - this got solved with the /24 setting suggested above

  2. Because the nginx proxy manager addon changes its docker IP, it seems like it can get any IP whatsoever, including the one used by my DeConz addon (I guess it started before the DeConz addon and snatched the IP first). This breaks the link between the DeConz addon and the DeConz integration, since the integration discovers an IP when being set up, so is thus hard-coded to the DeConz addon IP at the time of configuration.

For this problem, inputting the DeConz addon host instead of its IP in the DeConz integration would indeed be great, but I wanna be sure I can do that before deleting the existing DeConz integration :slight_smile:

When going for the manual setup of the DeConz integration, I see it asks for a host and a port, so not 3 items like you mentioned above.

1 Like

Ah, unfortunately, HA and the addons are on separate docker networks (HA is on host, the addons are on a specific “hassio”), so that won’t work, unfortunately.

That trick only works between containers on the same docker network.

EDIT: But as Tom said, there is some magic that would make core-deconz resolve.

1 Like

Shoot, it would have been nice to have that working :slight_smile:

Would there be any way, then, to assign a static Docker IP to the DeConz addon? Since the Nginx Proxy Manager addon doesn’t have an associated integration, I wouldn’t mind if it continues to move around to various IPs, but DeConz needs to stay put :slight_smile:

See my EDIT, ping core-deconz should work

Yeah, only between addons unfortunately. It’s no good for the integration.

Interesting, ping core-deconz does work, but yeah, I don’t think I can use it for the integration, possibly because I’m missing a place in which to set an extra port, there’s only one host and one port to set.

Mmm… I just have the ssh addon, but that works from HA

$ docker exec -it homeassistant /bin/sh
/config # ping core-ssh
PING core-ssh (172.30.33.0): 56 data bytes
64 bytes from 172.30.33.0: seq=0 ttl=64 time=0.513 ms
64 bytes from 172.30.33.0: seq=1 ttl=64 time=0.421 ms
64 bytes from 172.30.33.0: seq=2 ttl=64 time=0.253 ms

EDIT: Works for core-configurator as well…

Does this help?

1 Like