diyhue / diyHue

Main diyHue software repo
https://diyhue.org/
Other
1.58k stars 280 forks source link

Reverse Proxy Documentation #1056

Open RowMax03 opened 5 days ago

RowMax03 commented 5 days ago

Feature does not already exist?

I searched and did not find an existing feature request

Summarize feature

I think many people run diyhue hue and their whole setup inside docker. The limitation that you need the http ports open in order to run diyhue is bad when using a reverse proxy for other services. I saw the issue and some solutions but they where 5 years old and the source code looks way different now.

Especially a documentation to have some specific traefik rule to forward only hue request to port 80 or 443 internally would be great because setting a host name doesn't work if I understood correctly.

hendriksen-mark commented 5 days ago

Hi, first the hue app requires port 80 and 443. You want te be able to rout the ports inside to a different port, so diyhue listen to port 8080 and 8443 and out side it is reachable on port 80 and 443?

RowMax03 commented 4 days ago

Depending on how the url parameters are you could also very specifically route some traffic to to diyhue. For example everything to /api on the ip adress itself could get routed to diyhue using traefik. Or things that alway appear in the header. Being able to change the port in the docker compose would also work I guess.

hendriksen-mark commented 4 days ago

I i understand you correctly, you want to redirect url endpoints to something else? Why would you want to do that? We replicate what the original bridge does, we are not going to change the api or add a api because there is no benefit. If you want to change that in docker you may but that is out of our scope.

eckynde commented 4 days ago

I also have a docker compose and traefik reverse proxy setup and I'm looking to add diyhue. Not sure when I'll get to it but once I've figured it out I'll post my config here.

Traefik listens on 80 and 443 and proxies to different services/web servers using rules, mostly by checking the host in the http request (subdomain). Doing this has many benefits like SSL offloading and running multiple services on a server with just one IP.

In a perfect world we would be able to use a subdomain to reach the diyhue bridge emulator, but from what I gather, the apps are limited to IP only.

This shouldn't be a problem though: It should be possible to configure traefik to send any http/https traffic for the IP (no subdomain) to the diyhue container. Any traffic to a subdomain still goes to the other services.

As for the diyhue container, it can continue running using default http/https ports, but we do not publish them in the docker compose file anymore. The ports are still accessible from the docker network but docker won't try binding those ports on the host. Which is good because those ports are already bound by traefik. Instead we can put the diyhue container on the proxy/traefik network and configure traefik to send requests for the ip (with no host/subdomain) to diyhue.

Here are some links to some potential puzzle pieces:

As I wrote above, I'll be sure to update you when I've had the time to actually put my plan to the test, but maybe this already gives you a couple ideas.

Home Assistant Community
[GUIDE] Using the Hue App with Home Assistant (via DiyHue)
I wanted to use the Hue App to control Home Assistant lights as some members of the family prefer the Hue App to the Home Assistant interface. So I set out to add Home Assistant integration into diyHue (https://diyhue.org/) and as luck would have it at the same time @MaxBec92 created the DiyHue Addon that has now been included in the diyhue project (https://github.com/diyhue/hassio-addon) here is how to configure everything you need to get the Hue App working to control Home Assistant lights… B...
Traefik Labs Community Forum
Routing rule for IP instead of hostname
You can use Host(`1.2.3.4`) for http routers. At least browsers send the IP in the HTTP Host header, so it can be matched by Traefik.
hendriksen-mark commented 4 days ago

you can change the port of diyhue with docker environment variable HTTP_PORT and HTTPS_PORT or commandline argument --http-port and --https-port

RowMax03 commented 2 days ago

Can I choose any port or just 80/443 and 8080/8443?

hendriksen-mark commented 2 days ago

you can use any port except 1900 and 2100, the hue app needs 80 and 443 its not possible to change that.