Limit website and hugo admin to subdirectory access?

Hi,
2 questions:

1) I have this directory structure:

caddy/caddy (executeable server)
caddy/firstdomain.com/index.html
caddy/seconddomain.com/index.html

and this Caddyfile:

firstdomain.com {
        root firstdomain.com
        basicauth /admin username password
        hugo
}

seconddomain.com {
        root seconddomain.com
        basicauth /admin username password
        hugo
}

I first tried this with localhost, and with hugo admin I was able to navigate back to caddy directory. How can I prevent it, and have separate hugo admin for each domain?

2) Is it possible to to change hugo /admin url to /somethingelse ?

Best Regards,
xet7

1 Like

Hey @xet7!

1) I’m not understanding a thing: isn’t Hugo supposed to generate the website to a folder like /public? If the directory structure was:

caddy/firstdomain.com -> Hugo Website
caddy/firstdomain.com/public -> Generated Website
caddy/seconddomain.com -> Hugo Website
caddy/seconddomain.com/public -> Generated Website

your Caddyfile would have to look like this one:

firstdomain.com {
        root firstdomain.com/public
        basicauth /admin username password
        hugo firstdomain.com
}

seconddomain.com {
        root seconddomain.com/public
        basicauth /admin username password
        hugo seconddomain.com
}

In that way, from each site, you only could access its own folder.

2) It’s not possible right now, but it’s something very easy to implement. I’ll open an issue on GitHub and do that ASAP. :slight_smile:

I hope it helps! Have a nice day! :smiley:

1 Like