HUGO

Stop hugo to use 1313 port

I run my docker hugo with : CMD hugo server -b ${HUGO_BASE_URL} --bind=0.0.0.0,
the result is https://myurl:1313. I need to have the url without any port as the result. How can I run hugo for this matter?
I set the port on my server-side and need to disable it. hugo version: 0.68.2 , extended version.

Hi,

Using argument “-p”/"–port" will make it possible to change the port used.

I fully trust @bep and the Hugo product, however I’d never use the built-in Hugo server to serve my website in production, and especially not visible to the whole world. If you are looking for an out-of-the-box solution, please see how Hugo may be combined to build an image where nginx is used to serve your webpage:

1 Like

I want the url without any port number after that. I know about -p but it does not answer my question. It is visible to the outside world. However, the production server has own specific requirements. Right now, I am using the docker image by https://github.com/publysher/docker-hugo/blob/master/Dockerfile
and I see there is Nginx on the build line.

The default port for “http” is 80, thus setting port to port 80 will result in no need to specify port for “http”.

The Docker image you point to does not result in an image using nginx, I’d still propose the solution I linked to. (Bonus: the image you end up with uses port 80.)

So, if I use -p 80:80 then the url will be serve without anu port attached to it? Sorry, it might be silly, but can you point me to an image that uses the nginx to serve website.

When you override port when running “hugo server [-p]” to change the port used by hugo, you must also change the docker command accordingly. If you do not override port used by hugo and want to change only the docker port binding, then may “-p 80:1313” be used. Information regarding use of docker on this matter is available here:

The link in my first answer should make to jump directly to the “Using an ONBUILD image” section containing a concrete example for Dockerfile resulting in an image using nginx for publishing.

You mean this part
FROM klakegg/hugo:0.68.3-onbuild AS hugo

FROM nginx
COPY --from=hugo /target /usr/share/nginx/html

Yes, that is a copy of the example provided.

Thanks, but still I got the same result after running the docker:
docker run -p 80:1313 -it (imagename)
https://myurl:1313/

@bep any solution for this problem. I use CMD hugo server --port=80 -b ${HUGO_BASE_URL}, then webservers everytime gives me a new port.

Does the log contain the following message?

port 80 already in use, attempting to use an available port

no not really. I made it free.
CMD hugo server --port=80 -b ${HUGO_BASE_URL}
then what I got https://myurl:3456 and next time another number :slight_smile: