# Docker: bad resource urls in main page

**URL:** https://community.metabrainz.org/t/docker-bad-resource-urls-in-main-page/639117
**Category:** Development
**Created:** [May 29, 2023, 9:54am UTC](https://community.metabrainz.org/t/docker-bad-resource-urls-in-main-page/639117 "2023-05-29T09:54:14Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![bendera](https://community.metabrainz.org/letter_avatar_proxy/v4/letter/b/a3d4f5/32.png) [@bendera](https://community.metabrainz.org/u/bendera)
#### Post date: [May 29, 2023, 9:54am UTC](https://community.metabrainz.org/t/docker-bad-resource-urls-in-main-page/639117/1 "2023-05-29T09:54:14Z")

</div>

Hi, I’m trying to setup the Musicbrainz Server with Docker on a v-server, running behind Nginx which is acting as reverse proxy.

When I navigate to the website the stylesheets and javascript files are not loaded, and having a look at the index page I could find urls like this:

`<link href="//localhost:5000/static/build/icons-3a8c753.css" rel="stylesheet" type="text/css"/>`

I already found out that I could change the domain name by setting `MUSICBRAINZ_WEB_SERVER_HOST` to my Domain, which replaced `localhost` with my Domain just fine, so I have something like:

`<link href="//mydomain:5000/static/build/icons-3a8c753.css" rel="stylesheet" type="text/css"/>`

Now the problem is, that I also need to get rid of the port part. I found the `MUSICBRAINZ_WEB_SERVER_PORT` but changing this to 443 doesn’t work. If I do this the Musicbrainz server tries to run on 443, but of course my Nginx is already blocking this.

Can somebody tell me how I get rid of the port in the Website, is there any other property to change this? I’m sorry if this is documented somewhere and I didn’t find it.

Thank you in advance, kind regards  
Andreas

---

<div class="post-metadata">

### Author: ![jesus2099](https://community.metabrainz.org/user_avatar/community.metabrainz.org/jesus2099/32/36_2.png) [@jesus2099](https://community.metabrainz.org/u/jesus2099)
#### Post date: [May 29, 2023, 11:24am UTC](https://community.metabrainz.org/t/docker-bad-resource-urls-in-main-page/639117/2 "2023-05-29T11:24:03Z")

</div>

[Apparently](https://community.metabrainz.org/t/custom-url-with-musicbrainz-docker/514402/4) you can omit `MUSICBRAINZ_WEB_SERVER_PORT` in your case as port `80` is default for `HTTP` and `443` is default for `HTTPS`.

It should work thanks to [yvanzo patch](https://community.metabrainz.org/t/custom-url-with-musicbrainz-docker/514402/2), but if it doesn’t, maybe have a look at the `build/musicbrainz/DBDefs.pm` file.

---

<div class="post-metadata">

### Author: ![yvanzo](https://community.metabrainz.org/user_avatar/community.metabrainz.org/yvanzo/32/2864_2.png) [@yvanzo](https://community.metabrainz.org/u/yvanzo)
#### Post date: [May 29, 2023, 1:28pm UTC](https://community.metabrainz.org/t/docker-bad-resource-urls-in-main-page/639117/3 "2023-05-29T13:28:45Z")

</div>

The default port is `5000` (@jesus2099 mixed it up) as explained in “[Advanced configuration](https://github.com/metabrainz/musicbrainz-docker#advanced-configuration)” which you seem to have followed correctly. It might be that the documentation to run on port 443 is outdated. I will look into it again. Running on port 80 should work though.

---

<div class="post-metadata">

### Author: ![bendera](https://community.metabrainz.org/letter_avatar_proxy/v4/letter/b/a3d4f5/32.png) [@bendera](https://community.metabrainz.org/u/bendera)
#### Post date: [May 29, 2023, 1:52pm UTC](https://community.metabrainz.org/t/docker-bad-resource-urls-in-main-page/639117/4 "2023-05-29T13:52:22Z")

</div>

Thanks for your help! Setting `MUSICBRAINZ_WEB_SERVER_PORT` to 80 indeed works, if I then change my Nginx HTTP port to something different, e.g. 81, since they run on the same server.

But since the Nginx is the reverse proxy for multiple applications I would prefer that it keeps using 80/443.

Is it somehow possible that the Musicbrainz server is running on port 5000 (or any else except 80/443), but that the Website doesn’t add the port number?

---

<div class="post-metadata">

### Author: ![outsidecontext](https://community.metabrainz.org/user_avatar/community.metabrainz.org/outsidecontext/32/90_2.png) [@outsidecontext](https://community.metabrainz.org/u/outsidecontext)
#### Post date: [May 29, 2023, 4:16pm UTC](https://community.metabrainz.org/t/docker-bad-resource-urls-in-main-page/639117/5 "2023-05-29T16:16:48Z")

</div>

If you serve the MB server on a non standard port the port number must be added behind the host name.

But if you have a mind reverse proxy anyway you can configure it to serve your MB installation.

---

<div class="post-metadata">

### Author: ![bendera](https://community.metabrainz.org/letter_avatar_proxy/v4/letter/b/a3d4f5/32.png) [@bendera](https://community.metabrainz.org/u/bendera)
#### Post date: [May 29, 2023, 5:27pm UTC](https://community.metabrainz.org/t/docker-bad-resource-urls-in-main-page/639117/6 "2023-05-29T17:27:06Z")

</div>

Yes, I’m using Nginx as reverse proxy. I also set `MUSICBRAINZ_USE_PROXY=1` in my `.env` file, but this doesn’t seem to have any effect. When opening the website the Stylesheet and Javascript references still have the port number added.

---

<div class="post-metadata">

### Author: ![yvanzo](https://community.metabrainz.org/user_avatar/community.metabrainz.org/yvanzo/32/2864_2.png) [@yvanzo](https://community.metabrainz.org/u/yvanzo)
#### Post date: [May 29, 2023, 7:57pm UTC](https://community.metabrainz.org/t/docker-bad-resource-urls-in-main-page/639117/7 "2023-05-29T19:57:48Z")

</div>

Indeed the problem is port collision with the reverse proxy, whereas the documentation seems to assume that the reverse proxy would be hosted on a separate machine.

Instead of running on a different port than `80`, you can try publishing the port on another network interface than the host loopback, since Docker is usually running its own network interface(s), as follows:

```bash
# assuming that both host and port (80) are customized
docker_network_name=$(docker-compose config --format json | jq -r '.networks.default.name')
docker_gateway_ip=$(docker network inspect --format json "$docker_network_name" | jq -r '.[].IPAM.Config[].Gateway')
echo "MUSICBRAINZ_DOCKER_HOST_IPADDRCOL=${docker_gateway_ip}:" >> .env
unset docker_network_name docker_gateway_ip
docker-compose up -d musicbrainz

```

In case your reverse proxy is running on Docker too, and use the same Docker network interface, you would have to add an override to make it use a separate network.

---

<div class="post-metadata">

### Author: ![bendera](https://community.metabrainz.org/letter_avatar_proxy/v4/letter/b/a3d4f5/32.png) [@bendera](https://community.metabrainz.org/u/bendera)
#### Post date: [May 30, 2023, 7:10pm UTC](https://community.metabrainz.org/t/docker-bad-resource-urls-in-main-page/639117/8 "2023-05-30T19:10:21Z")

</div>

Thanks a lot for your help and sorry for the late reply! Unfortunately using your commands resulted in the following error when I tried to start the container:

> Error response from daemon: driver failed programming external connectivity on endpoint musicbrainz-docker-musicbrainz-1 (c65568e8e704172cb5f4f14f575416777da9d8da9967af4a657eff2dcd0c41d4): Error starting userland proxy: listen tcp4 172.19.0.1:80: bind: cannot assign requested address

I’m not that experienced with docker and don’t fully get what the problem is. It doesn’t sound like the port is already in use, but something else, maybe permissions? (But I tried to use `sudo` that didn’t have any effect)

I experimented a bit around and thought maybe I could trick the setup a bit. So I tried the following:

Set `MUSICBRAINZ_WEB_SERVER_PORT=80` in my `.env` file so the port number is removed in the stylesheet links, but manually specify port 5000 in the `docker-compose.yml`:

```auto
  musicbrainz:
    ports:
# - "${MUSICBRAINZ_DOCKER_HOST_IPADDRCOL:-}${MUSICBRAINZ_WEB_SERVER_PORT:-5000}:5000"
      - "5000:5000"

```

That does work, at least I can open the website now under my domain with stylesheets/javascripts. But of course I know that the `docker-compose.yml` should remain untouched if possible.

Maybe you have another idea, or know why that docker error message was returned?

What confuses me a bit is, why is the domain and port added to the stylesheet links at all per default? At least in my mind the default should be a relative path, so it doesn’t matter if the website is running behind a reverse proxy or not, and that specifying an absolute path with domain and port should be something you explicitely need to do if necessary. But I guess you have reasons to do this, but I find it a bit counterintuitive. (No offense! 🙂 )

---

<div class="post-metadata">

### Author: ![yvanzo](https://community.metabrainz.org/user_avatar/community.metabrainz.org/yvanzo/32/2864_2.png) [@yvanzo](https://community.metabrainz.org/u/yvanzo)
#### Post date: [May 30, 2023, 9:27pm UTC](https://community.metabrainz.org/t/docker-bad-resource-urls-in-main-page/639117/9 "2023-05-30T21:27:32Z")

</div>

> [@bendera](#):
>
> Set `MUSICBRAINZ_WEB_SERVER_PORT=80` in my `.env` file […] but manually specify port 5000 in the `docker-compose.yml`

Good finding. I have no better suggestion.

Unfortunately the repository doesn’t handle some use cases like this one correctly. There are plans to heavily refactor it to make it more flexible and more ready to use.

> [@bendera](#):
>
> What confuses me a bit is, why is the domain and port added to the stylesheet links at all per default?

The default behavior has been set 10 years ago, not sure what was the reason. In production, those files are served from a different domain, so it isn’t using the default value. In mirrors, it has probably never been set. I will investigate whether that can be removed by default or for mirrors at least. Thanks for reporting!

---

<div class="post-metadata">

### Author: ![bendera](https://community.metabrainz.org/letter_avatar_proxy/v4/letter/b/a3d4f5/32.png) [@bendera](https://community.metabrainz.org/u/bendera)
#### Post date: [May 31, 2023, 5:42pm UTC](https://community.metabrainz.org/t/docker-bad-resource-urls-in-main-page/639117/10 "2023-05-31T17:42:22Z")

</div>

Alright, thanks a lot for your time and help! I’ll stick with the workaround for now since that seems to be working.
