jcgoette / baby_buddy_homeassistant

This custom integration provides sensors for Baby Buddy API endpoints.
MIT License
60 stars 28 forks source link

Services stopped working with latest update #60

Closed sfgabe closed 2 years ago

sfgabe commented 2 years ago

I updated baby buddy and home assistant at the same time so I'm not sure which one is the culprit, but services stopped working as of the 1 April home assistant update.

Happen to anyone else? Any ideas what it could be?

jcgoette commented 2 years ago

I'm guessing your docker-compose.yaml looks similar to this?

services:
 app:
  environment:
   - CSRF_TRUSTED_ORIGINS=http://localhost:8000
   - DJANGO_SETTINGS_MODULE=babybuddy.settings.base
  image: ghcr.io/linuxserver/babybuddy
  ports:
   - '8000:8000'

If so, I'm able to reproduce the issue:

http://localhost:8000/api/ returns: {"children":"http://localhost/api/children/","changes":"http://localhost/api/changes/","feedings":"http://localhost/api/feedings/","notes":"http://localhost/api/notes/","sleep":"http://localhost/api/sleep/","temperature":"http://localhost/api/temperature/","timers":"http://localhost/api/timers/","tummy-times":"http://localhost/api/tummy-times/","weight":"http://localhost/api/weight/","height":"http://localhost/api/height/","head-circumference":"http://localhost/api/head-circumference/","bmi":"http://localhost/api/bmi/"}.

I think the problem may be here:

https://github.com/linuxserver/docker-babybuddy/blob/21b1afc9405d70aba0630054fdd07e0a6ff22a0e/root/defaults/default#L12

When I change the LSIO nginx.conf from proxy_set_header Host $host; to proxy_set_header Host $http_host;, all works as expected:

{"children":"http://localhost:8000/api/children/","changes":"http://localhost:8000/api/changes/","feedings":"http://localhost:8000/api/feedings/","notes":"http://localhost:8000/api/notes/","sleep":"http://localhost:8000/api/sleep/","temperature":"http://localhost:8000/api/temperature/","timers":"http://localhost:8000/api/timers/","tummy-times":"http://localhost:8000/api/tummy-times/","weight":"http://localhost:8000/api/weight/","height":"http://localhost:8000/api/height/","head-circumference":"http://localhost:8000/api/head-circumference/","bmi":"http://localhost:8000/api/bmi/"}

I am going to open a PR with LSIO and see what they think.

Thanks all.

myxor commented 2 years ago

@jcgoette great catch! I haven't even thought about the Lsio docker image having a nginx proxy as well...

Let's hope on a quick merge! Thanks for your help!

myxor commented 2 years ago

@jcgoette i tried out the potential fix from https://github.com/linuxserver/docker-babybuddy/pull/19 but sadly it does not fix the problem on my side.

shaner-git commented 2 years ago

I also had the same error when trying to call a service through the internal docker network, which previously worked:

Cannot connect to host babybuddy:80 ssl:default [Connect call failed ('172.20.0.2', 80)]

After modifying my docker compose to the following, service calls began working as expected.

  ports:
   - '8000:8000'
   - '80:80'
jcgoette commented 2 years ago

Closed by https://github.com/linuxserver/docker-babybuddy/pull/19.

kazzaw commented 2 years ago

I still have this issue with the most recent update from lsio. Anyone else?

danepowell commented 2 years ago

Yeah this is still broken in Baby Buddy v1.10.2-ls33

jcgoette commented 2 years ago

ls33 is from 4/17. This fix looks like it was put on https://github.com/linuxserver/docker-babybuddy/releases/tag/v1.10.2-ls36.

danepowell commented 2 years ago

Sorry, still a problem with v1.10.2-ls37 as well (have I mentioned how much I hate Docker versioning and "tags"? 😄)

I tried explicitly exposing port 8000 on the babybuddy container to no effect. I cannot expose port 80 (already in use), nor would I want to.

kazzaw commented 2 years ago

I am running 1.10.2-ls36 just FYI

jcgoette commented 2 years ago

I mistakenly thought the PR would fix this automatically. You will still need to take some action. See links below:

myxor commented 2 years ago

Manually changing the mounted file /config/nginx/site-confs/default and restarting the container fixes the problem! thanks everyone!

kazzaw commented 2 years ago

Can you confirm what you changed? Appreciated

myxor commented 2 years ago

I mounted /config as a volume of the container and the change from this commit: https://github.com/linuxserver/docker-babybuddy/pull/19/files in the file /config/nginx/site-confs/default.