GioF71 / mpd-alsa-docker

Easily run mpd with Alsa or PulseAudio output with Docker. Upsampling 2x 4x 8x with "Goldilocks" settings by Archimago. Scrobbling support.
Apache License 2.0
18 stars 5 forks source link

[Enhancement] Add multiple bind to address support #357

Closed vari closed 7 months ago

vari commented 7 months ago

It would be nice to be able to specify multiple bind to address values for MPD.

Context: I'd like to have MPD listen via the standard 0.0.0.0 address as well as via unix file socket. The unix file socket is necessary for adding music files to MPD's queue using absolute file paths (e.g. if I wanted to play files that are not in the /music directory). While I could switch to exclusively using the unix file socket via the existing MPD_BIND_ADDRESS var, I'd like to have MPD also listen via TCP at 0.0.0.0 so that my phone MPD client can connect to it as well.

GioF71 commented 7 months ago

Hello, sure, will do that, maybe today but I cannot guarantee. Can you explain me the use case? For my own understading. On my desktop I used to use Cantata (unfortunately discontinued) which could create an http server for streaming local files. Thank you

vari commented 7 months ago

My setup is a little complicated but basically, I have a separate mount point (lets call it /tmpMusic) in addition to the standard /music mount attached to the MPD container. In /tmpMusic, I like to add some temporary music that I don't necessarily want in my normal library yet, but I would still like to have MPD play music in that directory sometimes. I don't want MPD to index those files since its not part of my normal /music library. This is part of a larger setup which is beyond the scope of this issue but basically I have a MPD client that connects to MPD via UNIX socket to issue the commands to play /tmpMusic files (due to MPD's requirement of using UNIX sockets when specifying filepaths outside of the /music directory). This works fine but I can no longer use a MPD client on my phone to listen to music if MPD is not also listening on 0.0.0.0.

I think a simpler and likely more common use case would be something like wanting to use one bind_to_address to listen to requests from localhost and one bind_to_address to listen on a specific IP (perhaps the IP via which a reverse proxy forwards traffic to MPD). The default listen to 0.0.0.0 address would work in this scenario, but having two separate bind addresses might provide better security since you only accept connections from localhost and on that one IP used for the reverse proxy.

maybe today but I cannot guarantee.

Thanks for being so responsive and resolving this and the other issues I filed so quickly 😄

GioF71 commented 7 months ago

Hello, so did the change work for you? Would you share your compose file or docker run command?

Thank you!

vari commented 7 months ago

Yep, the changes worked perfectly.

Here's a simplified version of my compose file:

services:
  mpd:
    container_name: 'mpd'
    image: 'giof71/mpd-alsa:vanilla-latest'
    restart: unless-stopped
    environment:
      RESTORE_PAUSED: "yes"
      DEFAULT_PERMISSIONS: "read"
      PASSWORD: "REDACTED"
      MPD_BIND_ADDRESS: "/var/run/mpd/socket"
      MPD_BIND_ADDRESS_1: "0.0.0.0"

      # Icecast streaming
      SHOUT_OUTPUT_CREATE: "yes"
      SHOUT_OUTPUT_ENABLED: "yes"
      SHOUT_OUTPUT_HOST: icecast
      SHOUT_OUTPUT_PORT: 8000
      SHOUT_OUTPUT_MOUNT: "/icecast"
      SHOUT_OUTPUT_USER: "REDACTED"
      SHOUT_OUTPUT_PASSWORD: "REDACTED"
      SHOUT_OUTPUT_ALWAYS_ON: "yes"
    ports:
      - '6600:6600'
    volumes:
      - ./mpd/db:/db
      - ./playlists:/playlists
      - ./mpd/log:/log
      - ./mpd/config:/user/config
      - ./mpd/socket:/var/run/mpd/
      # Music dir - path to normal music library
      - ./music:/music
      # Temp music dir for adhoc playing of music not in the regular /music library. Client must use socket for this
      - ./tmpMusic:/tmpMusic
GioF71 commented 7 months ago

Hello, thank you for sharing your configuration. May I ask which client do you use? Just curious. For a scenario very similar to yours, I tend to stick with upnp: I have a MiniDlna instance (also running docker image here) on that "tmpMusic", and then use any control point to play from that library.

In any case I am happy that you can use my container in your setup!

vari commented 7 months ago

My setup is in flux (mostly just playing around with MPD and trying to get more familiar with it). Currently using mympd but looking into other clients. Will take a look at MiniDLNA as well - thanks for the suggestion!