Unable to reach docker containers via web, while using nginx (non docker version)

Hello! I hope I’m at the right place. So basically, I have nginx installed on my RaspberryPi, working perfectly fine. It’s configured with Let’s Encrypt, enforcing https.

I am now playing with docker, attempting to run navidrome following the guide here: Installing and Running Navidrome on the Raspberry Pi - Pi My Life Up, where I get stuck on step 10.

I cannot access the url:port at all. Even though I have the port enabled. Now I have been trying to google like mad for this on how “it” works when I have a “native” nginx installed and configured + now also wanting to run docker images with webUI’s. But every hit I get relates to issues with nginx VIA docker and other images.

I am fairly certain it’s a configuration thing but I do not know where to look.

Have anybody else have had issues like this while using docker images while at the same time running an nginx installation “natively” outside docker?

I’ll gladly post more information, configs etc. if needed :slight_smile:

How do you try to access the webapp? From your local PC in your local network to the Pi?

The container is supposed to use ports: - "4533:4533", so it should be totally independent of nginx.

Run docker ps to see if the container is even running. Run netstat -tulpn to see if the port is opened.

If you want to proxy to your Docker services automatically by (sub-)domain, check nginx-proxy or simple Traefik example.

1 Like

Hello! Local PC yes, however the same results if I use the local ip (192.168…) Public IP or the DNS name I have setup. Works fine for my nginx on port 80 and 443

docker ps

CONTAINER ID   IMAGE                     COMMAND            CREATED         STATUS                   PORTS                                       NAMES
ab9a8e4d0b81   deluan/navidrome:latest   "/app/navidrome"   7 minutes ago   Up 7 minutes (healthy)   0.0.0.0:4533->4533/tcp, :::4533->4533/tcp   navidrome-navidrome-1

netstat -tulpn

(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:10000           0.0.0.0:*               LISTEN      -
tcp        0      0 0.0.0.0:4533            0.0.0.0:*               LISTEN      -
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      -
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      -
tcp6       0      0 :::4533                 :::*                    LISTEN      -
tcp6       0      0 :::22                   :::*                    LISTEN      -
tcp6       0      0 ::1:25                  :::*                    LISTEN      -
udp        0      0 0.0.0.0:68              0.0.0.0:*                           -
udp        0      0 0.0.0.0:5353            0.0.0.0:*                           -
udp        0      0 0.0.0.0:10000           0.0.0.0:*                           -
udp        0      0 0.0.0.0:39366           0.0.0.0:*                           -
udp6       0      0 :::43153                :::*                                -
udp6       0      0 :::5353                 :::*                                -

docker logs --tail 50 --follow --timestamps navidrome-navidrome-1

2024-01-24T20:44:23.751949347Z  _   _             _     _
2024-01-24T20:44:23.752183670Z | \ | |           (_)   | |
2024-01-24T20:44:23.752219868Z |  \| | __ ___   ___  __| |_ __ ___  _ __ ___   ___
2024-01-24T20:44:23.752249138Z | . ` |/ _` \ \ / / |/ _` | '__/ _ \| '_ ` _ \ / _ \
2024-01-24T20:44:23.752277836Z | |\  | (_| |\ V /| | (_| | | | (_) | | | | | |  __/
2024-01-24T20:44:23.752305649Z \_| \_/\__,_| \_/ |_|\__,_|_|  \___/|_| |_| |_|\___|
2024-01-24T20:44:23.752334034Z                           Version: 0.51.0 (fd61b29a)
2024-01-24T20:44:23.752361118Z
2024-01-24T20:44:23.772737628Z time="2024-01-24T20:44:23Z" level=info msg="goose: no migrations to run. current version: 20231209211223\n"
2024-01-24T20:44:23.774218721Z time="2024-01-24T20:44:23Z" level=info msg="Starting signaler"
2024-01-24T20:44:23.774441273Z time="2024-01-24T20:44:23Z" level=error msg="Agent not available. Check configuration" name=lastfm
2024-01-24T20:44:23.775066638Z time="2024-01-24T20:44:23Z" level=error msg="Agent not available. Check configuration" name=spotify
2024-01-24T20:44:23.775778461Z time="2024-01-24T20:44:23Z" level=info msg="Creating Image cache" maxSize="100 MB" path=/data/cache/images
2024-01-24T20:44:23.775895232Z time="2024-01-24T20:44:23Z" level=info msg="Configuring Media Folder" name="Music Library" path=/music
2024-01-24T20:44:23.776712003Z time="2024-01-24T20:44:23Z" level=info msg="Finished initializing cache" cache=Image elapsedTime=1.2ms maxSize=100MB
2024-01-24T20:44:23.792632784Z time="2024-01-24T20:44:23Z" level=info msg="Starting scheduler"
2024-01-24T20:44:23.794303200Z time="2024-01-24T20:44:23Z" level=info msg="Scheduling periodic scan" schedule="@every 1h"
2024-01-24T20:44:23.794839658Z time="2024-01-24T20:44:23Z" level=info msg="Setting Session Timeout" value=24h
2024-01-24T20:44:23.801068356Z time="2024-01-24T20:44:23Z" level=info msg="Login rate limit set" requestLimit=5 windowLength=20s
2024-01-24T20:44:23.801998565Z time="2024-01-24T20:44:23Z" level=info msg="Found ffmpeg" path=/usr/bin/ffmpeg
2024-01-24T20:44:23.802547419Z time="2024-01-24T20:44:23Z" level=info msg="Spotify integration is not enabled: missing ID/Secret"
2024-01-24T20:44:23.813613252Z time="2024-01-24T20:44:23Z" level=info msg="Mounting Native API routes" path=/api
2024-01-24T20:44:23.816480439Z time="2024-01-24T20:44:23Z" level=error msg="Agent not available. Check configuration" name=lastfm
2024-01-24T20:44:23.816637158Z time="2024-01-24T20:44:23Z" level=error msg="Agent not available. Check configuration" name=spotify
2024-01-24T20:44:23.817160648Z time="2024-01-24T20:44:23Z" level=info msg="Creating Transcoding cache" maxSize="100 MB" path=/data/cache/transcoding
2024-01-24T20:44:23.820006429Z time="2024-01-24T20:44:23Z" level=info msg="Finished initializing cache" cache=Transcoding elapsedTime=1.1ms maxSize=100MB
2024-01-24T20:44:23.822815179Z time="2024-01-24T20:44:23Z" level=info msg="Mounting Subsonic API routes" path=/rest
2024-01-24T20:44:23.824789397Z time="2024-01-24T20:44:23Z" level=error msg="Agent not available. Check configuration" name=lastfm
2024-01-24T20:44:23.825203668Z time="2024-01-24T20:44:23Z" level=error msg="Agent not available. Check configuration" name=spotify
2024-01-24T20:44:23.825962522Z time="2024-01-24T20:44:23Z" level=info msg="Mounting Public Endpoints routes" path=/share
2024-01-24T20:44:23.826723408Z time="2024-01-24T20:44:23Z" level=info msg="Mounting LastFM Auth routes" path=/api/lastfm
2024-01-24T20:44:23.827457418Z time="2024-01-24T20:44:23Z" level=info msg="Mounting ListenBrainz Auth routes" path=/api/listenbrainz
2024-01-24T20:44:23.828346168Z time="2024-01-24T20:44:23Z" level=info msg="Mounting Background images routes" path=/backgrounds
2024-01-24T20:44:23.828940387Z time="2024-01-24T20:44:23Z" level=info msg="Mounting WebUI routes" path=/app
2024-01-24T20:44:23.882822782Z time="2024-01-24T20:44:23Z" level=info msg="----> Navidrome server is ready!" address="0.0.0.0:4533" startupTime=115.6ms tlsEnabled=false
2024-01-24T20:44:25.799476650Z time="2024-01-24T20:44:25Z" level=error msg="Media Folder is empty. Aborting scan." folder=/music

  • What error does the browser return?
  • What happens when you use curl from RPI?
    curl localhost:4553
    
    and when you use the IP address instead of localhost.

Where did you need to enable the port? On a rooter, firewall or on the RPI locally?

Yeah stupid of me to not include basic info like that, sorry I’m just exhausted but refuse to give up :stuck_out_tongue:

  1. The error was an ‘unable to connect’ unfortunately I don’t remember the error code, because I have another situation now.

  2. curl returns the html data for my nginx server default index.html “welcome to nginx blah blah” (weird since i did curl localhost:4533 lol?

  3. The routing is done via my router via Virtual Port / Port Forwarding. For the internet → RaspPi server access. However, I also have it “enable” as in allow traffic for 4533 via ufw that I use on the server.

BUT.

I did some testing. Which hopefully might help? So I tried:

  1. I stopped nginx, ‘sudo systemctl stop nginx’ along with ‘docker compose down
  2. I launched the image again, docker compose up -d
  3. Again tried to browse to the IP both the local 192.168…:4533 IP, and it… works? I now tried the public IP, works?!

So I thought, fair enough then, I’ll try to launch nginx back up. ‘sudo systemctl start nginx’ and received an error, so I checked journalctl -xe and saw this all of a sudden:

Jan 24 23:00:10 raspberrypi nginx[6826]: nginx: [emerg] bind() to 0.0.0.0:4533 failed (98: Address already in use)
Jan 24 23:00:11 raspberrypi nginx[6826]: nginx: [emerg] bind() to 0.0.0.0:4533 failed (98: Address already in use)
Jan 24 23:00:11 raspberrypi nginx[6826]: nginx: [emerg] bind() to 0.0.0.0:4533 failed (98: Address already in use)
Jan 24 23:00:12 raspberrypi nginx[6826]: nginx: [emerg] bind() to 0.0.0.0:4533 failed (98: Address already in use)
Jan 24 23:00:12 raspberrypi nginx[6826]: nginx: [emerg] bind() to 0.0.0.0:4533 failed (98: Address already in use)
Jan 24 23:00:14 raspberrypi nginx[6826]: nginx: [emerg] still could not bind()
Jan 24 23:00:14 raspberrypi systemd[1]: nginx.service: Control process exited, code=exited, status=1/FAILURE

So naturally, I did the reverse thing… a) shut down the docker image, b) start nginx which now of course started fine. And now tried to start the docker image again and receive the following:

[+] Running 1/1
 ✔ Container navidrome-navidrome-1  Created                                                                                                                                                                                             0.0s
Error response from daemon: driver failed programming external connectivity on endpoint navidrome-navidrome-1 (4c1f638dd97417d70c45c3f41def9cc519412b1c6b5b13fadc0e74f8d6944974): Error starting userland proxy: listen tcp4 0.0.0.0:4533: bind: address already in use

Conclusion that I can make out of this, is that yeah there is some conflict with ip being already binded. But I don’t know why.

This is the configuration for the sites-available in nginx. (omitted some stuff)

server {
        listen 80 default_server;
        listen [::]:80 default_server;
        listen 443 ssl default_server;
        listen 4533 default_server;
        
        root /var/www/html;

        # Add index.php to the list if you are using PHP
        index index.html index.htm index.nginx-debian.html index.php default.php;

        server_name dns.name.tld;

        ssl_certificate thepath;
        ssl_certificate_key thepath;

        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                try_files $uri $uri/ =404;
        }

        #
        # pass PHP scripts to FastCGI server
        #
        location ~ \.php$ {
                include snippets/fastcgi-php.conf;
                fastcgi_pass unix:/run/php/php7.4-fpm.sock;
        }
}

More information!

I might be tired, but what I did was to remove

listen 4533 default_server;

From the sites-available config. And it now “works”. It seems like…
However I need to define HTTP IP : PORT to go to Navidrome. Will that aforementioned guides linked above help me with forcing it to also use HTTPS perhaps? So i can use HTTPS IP : PORT ?

Or is it something I have to sort out in my nginx config?

Well, you configured nginx to listen to port 4533 and your container to listen to 4533. It can’t be both, decide for one.

If you want a single point of entry through a proxy, I recommend nginx-proxy or Traefik (simple example) for automatic target discovery via env/labels.