baseURL and docker

Hi,

I am bumping into issues with baseURL and absURL parsing when running hugo from within a docker container.

config.toml
baseURL = “http://[hostname]:[port]/”

sudo docker run -d --rm -v /tmp/[path]:/src -p [port]:1313 -u hugo jguyomard/hugo-builder hugo server -w --bind=0.0.0.0

[hostname] => some hostname
[port] => some port
[path] => path to local hugo source directory

Will HUGO_BASEURL override this behavior?

The solution to my many problems seems to have a workaround in this trippy thread: [SOLVED] What should be used for the value of .Site.BaseURL?

Lol @ “trippy thread”. :rofl:

How does one suggest a documentation request around here?

You need to do a pull request at the Hugo Docs repo on Github.

There may be a feature gap here. Or, I am still confused. Not placing odds.

To render baseURL correctly in templates, I would need to do something like the following:

sudo docker run \
-d --rm -v ${srcdir}:/src \
-p ${vmport}:${hugoport} -u hugo \
jguyomard/hugo-builder \
hugo server -w --bind=${bindiface} --baseURL ${baseurl} --port ${hugoport}

${vmport} is the port used outside of the container, on which all resources are published (from the point of view of hugo service users.

${hugoport} is the port used by the hugo server, inside of the container. It gets baked into absURL (and maybe baseURL, not sure from the previous post).

${publishport} is the port used by the proxy server, exposed to the world at ${vmhostname}

Scenario:

bindport=1234
hugoport=2345
publishport=3456
vmhostname=somehost

Result:

absUrl = localhost:1234 # inside container
absUrl = localhost:2345 # outside container (as served by hugo)
upstream URL = somehost:3456 # outside of VM (served by a reverse proxy, translated to localhost:2345 by the proxy server)

But if hugo is serving localhost:2345 in hrefs and src attributes, then requests will come back to the proxy on the wrong port.

Is there another way to make it work that I am unaware of?

Have the proxy server do the re-write on the way back… Obviously…