Hugo theme link refers to container port in Docker/Nginx

I’ve got a simple static site, generated with Hugo, that I’m building to a Docker container running Nginx. Nginx is listening on port 90. I’m encountering strange behavior where certain links try to open the container port rather than the host port (in the case of localhost, it’s 8000). So for example, this link:

<a href="/documents">Docs</a>

…when moused-over shows that it will attempt to open localhost:8000/documents, which is correct, but when clicked it attempts instead to open http://localhost:90/documents/ (If I manually change the URL in the browser to http://localhost:8000/documents/, it responds fine.)

What makes this even stranger:

  1. Only certain links, specifically in the header menu, do this.
  2. I’ve used dozens of Hugo themes, and I’ve only encountered this issue with one of them: ZDoc. Could it be specific to this theme? That seems strange to me.

What could be causing this? I’m struggling to even know what this phenomenon is called. “Host/container port confusion”?

I’m certain it’s not a misconfiguration of Nginx or Docker. I’m exposing port 90 properly in my Dockerfile:


nginx.conf is set to listen on that port:

http {
    include    /etc/nginx/mime.types;
    sendfile on;
    server {
        root /usr/share/nginx/html/;
        index index.html;
        server_name localhost;
        listen 90;

And I’m starting the Docker container with the host port 8000 forwarding to the port Nginx is listening on:

docker run --name my-simple-site -p 8000:90 -d simple-site

$ docker ps
CONTAINER ID    IMAGE          COMMAND                  CREATED          STATUS          PORTS                   NAMES
de9cd1526034    simple-site    "nginx -g 'daemon of…"   41 minutes ago   Up 41 minutes>90/tcp    my-simple-site

Source: StackOverflow