Caddy 0.10.0 with Hugo 0.20.3

Hi everyone again, hope all is positive. My question is again related to the configuration of Caddy with Hugo. Before this I was working with Caddy alone with PHP and it works beautifully, today I wanted to add Hugo to it, basically this is the Caddyfile:

https://tour.testingsite.com {
    gzip
    tls luisalvaradox@gmail.com
    root /var/www/html/tour
    ext .php .html .htm
    fastcgi / 127.0.0.1:9000 php
    expires {
        match .js 30s
        match .css 30s
        match .html 30s
    }
}
https://test.testingsite.com {
    gzip
    tls luisalvaradox@gmail.com
    root /var/www/html/test
    ext .php .html .htm
    fastcgi / 127.0.0.1:9000 php
    expires {
        match .js 30s
        match .css 30s
        match .html 30s
    }
}

The above works perfectly between caddy and php. No problem there whatsoever. Now, if I add hugo which am basing it on the documentation and information thanks to Henrique I used this:

 https://tdc.eworkbox.com {
     gzip
     tls luisalvaradox@gmail.com
     root /var/www/html/tdc/public
     hugo /var/www/html/tdc {
         flag bind 0.0.0.0
     }
     basicauth /admin username password
     log stdout
     errors {
         log stderr
         404 404.html
     }
 }

I get this:

Activating privacy features… done.
2017/04/24 18:38:27 Caddyfile:37 - Parse error: Expecting a numeric status code or ‘*’, got ‘log’

And if I remove the whole error block I get this on the terminal:

Error: unknown flag: --bind

and the website shows a 404 Not Found message

Please let me know if I am missing anything else to explain the situation and obviously, what I am doing very wrong here. Thank you guys.

Looks like your errors directive has some bad syntax. Check out the errors doc - it’s expecting pairs of code file, where code is a status code and file is a file to serve when that code is generated by Caddy.

You’ve given it log stderr, and it’s trying to parse log as a status code.

It should probably be structured like this instead:

     errors stderr {
         404 404.html
     }

No idea what’s going on with the unknown --bind flag, that’s strange - Hugo definitely should handle that just fine…

You know what’s funny, I checked the error docs like 3 times and never thought that. Well it was pretty late and was working since 7am so maybe that’s why. Thank you very much @Whitestrake excellent work friend. That solved the issue.

FWIW the errors syntax did change slightly with 0.10, the log is now specified outside the block.

1 Like

Thank you Matt for the new information. +1 buddy

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.