esphome / feature-requests

ESPHome Feature Request Tracker
https://esphome.io/
421 stars 27 forks source link

Ability to configure dashboard listen address #2757

Open Daniel-dev22 opened 5 months ago

Daniel-dev22 commented 5 months ago

Describe the problem you have/What new integration you would like

I want to be able to configure the address the dashboard listens on. We can configure the port but not address.

Please describe your use case for this integration and alternatives you've tried:

The reason this matters is when using docker IPvlans the ports directive doesn't have any affect. So if you don't want to expose a port to a docker IPvlan it will still get exposed if the service is listening on that address. To stop this behavior, services would need to be set to not bind to all available addresses.

Additionally this also matters if you want to put Esphome when running in host network mode behind a reverse proxy like traefik as well as add authentication in front of the dashboard. The only way to do that and it actually be secured is to limit the address the dashboard listens on. For example adguard is running in host mode but since I can set the listen address that's not the host address so it's not exposed you have to go through traefik to get to the adguard dashboard.

Here's 2 examples where I was able to address this behavior.

In home assistant I can do this

http:
  server_host: 
    - 192.168.10.4

In adguard I can do this

http:
  address: 172.17.0.1:3000

Additional context

elnappo commented 1 month ago

That's already possible as you can see in the help message:

usage: esphome dashboard [-h] [--port PORT] [--address ADDRESS] [--username USERNAME] [--password PASSWORD] [--open-ui] [--socket SOCKET] configuration

positional arguments:
  configuration        Your YAML configuration file directory.

options:
  -h, --help           show this help message and exit
  --port PORT          The HTTP port to open connections on. Defaults to 6052.
  --address ADDRESS    The address to bind to.
  --username USERNAME  The optional username to require for authentication.
  --password PASSWORD  The optional password to require for authentication.
  --open-ui            Open the dashboard UI in a browser.
  --socket SOCKET      Make the dashboard serve under a unix socket

for example with esphome dashboard --address 127.0.0.1 config. What's still not working is setting a base path to place it behind a reverse proxy under a different path then /. There is already an open issue for that https://github.com/esphome/feature-requests/issues/2505