Explicit some_url/index.html returns empty page

I am trying to migrate a website from Apache to Caddy. Potentially there a lots of bookmarks pointing to some of my explicit index.html files. While caddy opens the page nicely, if the URL does not include the explicit ‘index.html’, it just shows an empty page, when the URL is complete as in ‘server.org - This website is for sale! - server Resources and Information.’.

I seem to be not able to configure Caddy to show the index.html content for both input URLs, with and without explicit ‘index.html’.

Is there and directive to achieve that? My Caddyfile is as follows:

http:// {
    	root /var/www
        index index.html index.php
        log /var/log/caddy/access.log
        errors /var/log/caddy/error.log

Hey @thomas, welcome to the Caddy community.

Caddy does serve an index file when you request a directory.

On the other hand, Caddy should never just give you a blank page, it will either serve the index file or an error. Getting a blank page implies that either the index file is blank or there’s an issue with the templates you’re using.

Hi Matthew,

thank you for the answer. When I specify an directory, the index file is served, but when I specify the index file directly, then an empty page is served. If I rename the index file on the server and give the full URL to the renamed file, then it is served. Thus, the syntax should be OK. The only template I use is the Include directive.

Do you have any ideas what to try? I am lost. Thanks in advance, Thomas

What version of Caddy are you running?

Caddy -version

I hit the same issue a while ago, never found a solution. I assume this is a feature of caddyserver: when referrring to the actual index page, you receive a blank page.

As a workaround, maybe you could try copying the index page to index2.html and refering in your index directive to index2.html, that way maybe you can refer to index.html explicitly and also receive the index when referring to /

Not quite. The behaviour has been for some time that Caddy’s static file server canonically redirects a visitor to the directory of the index, e.g. from /index.html to /. Then it serves the index from the directory. It should never serve a blank page.

Does this happen without the templates directive?

You are correct, I remembered it incorrectly. Just checked my old post again, indeed without the “templates” directive, you get a 301 redirect to /

I am using version 1.0.0, but the behavior was the same with an earlier version that I had installed some months ago.

I tried without the template directive in Caddyfile: With this, when addressing the index.html, then Caddy did serve its content. However, my server side includes are not resolved.

Sugarcube’s suggestion to use a second index file ‘index2.html’ and let the index directive point to it, would be a working workaround, but not really satisfactory.

I’m not sure what templates is doing to interfere, but it seems to be heading off the static file server before it can get its canonical redirect in, and serving a blank page instead.

Looks like we’re actually tracking this issue: https://github.com/mholt/caddy/issues/2114

Feel free to jump in over there and voice support for a fix. If someone could write up their workaround in that thread, too, that’ll be helpful in the interim.

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