V2: Directory index not appearing

1. My Caddy version (caddy version):


➜ caddy git:(master) git config --get remote.origin.url
➜ caddy git:(master) git rev-parse HEAD
➜ caddy git:(master) ./cmd/caddy/caddy version

2. How I run Caddy:

sudo ~jakobbg/storage/Files/caddy/cmd/caddy/caddy run --config /usr/local/www/Caddyfile

a. System environment:

➜ caddy git:(master) uname -a
FreeBSD core24.grimstveit.no 12.1-RELEASE-p4 FreeBSD 12.1-RELEASE-p4 3a7a11c8023(releng/12.1) CORE24 amd64

d. My complete Caddyfile or JSON config:

    email jakob@grimstveit.no

grimstveit.no {
    root * /data/www/docs/www.grimstveit.no
    encode zstd gzip
    file_server browse

3. The problem I’m having:

I’d like to replace php74, mod_apache, mod_userdir and mod_access (.htaccess). Currently not able to serve both php files using php_fastcgi and file_server at the same time from the same directory tree, as Apache2 would let me. I’d like, for example grimstveit.no/test to be browseable with automatic directory index without any php (not working!), grimstveit.no/test/script.php to be runnable via php_fastcgi (works) and grimstveit.no/test/file.txt to be output directly from file_server (works).

Currently I just get the HTML content of https://grimstveit.no/ (but no images are loaded) when I navigate to Index of /test

4. Error messages and/or full log output:

2020/05/05 00:31:20.867 INFO using provided configuration {“config_file”: “/usr/local/www/Caddyfile”, “config_adapter”: “”}
2020/05/05 00:31:20.867 INFO admin admin endpoint started {“address”: “tcp/localhost:2019”, “enforce_origin”: false, “origins”: [“localhost:2019”, “[::1]:2019”, “”]}
2020/05/05 00:31:20.868 INFO http server is listening only on the HTTPS port but has no TLS connection policies; adding one to enable TLS {“server_name”: “srv0”, “https_port”: 443}
2020/05/05 00:31:20.868 INFO http enabling automatic HTTP->HTTPS redirects {“server_name”: “srv0”}
2020/05/05 02:31:20 [INFO][cache:0xc000362e60] Started certificate maintenance routine
2020/05/05 00:31:20.869 INFO tls cleaned up storage units
2020/05/05 00:31:20.869 INFO http enabling automatic TLS certificate management {“domains”: [“grimstveit.no”]}
2020/05/05 00:31:20.875 INFO autosaved config {“file”: “/root/.config/caddy/autosave.json”}
2020/05/05 00:31:20.875 INFO serving initial configuration

5. What I already tried:

Tried reading docs, sorting the config file differently, but seems like I have to disable php_fastcgi in order to make “file_server browse” work. And I would actually BOTH to work in tandem, with only php_fastcgi to kick in when necessary.

What you’re running into is that the php_fastcgi directive is a shortcut that expands out to this config:

I think what’s specifically causing you trouble is the try_files rewrite. It sounds like you’re not using index.php files as fallback routes, so this might do the wrong thing for you.

I recommend you use just the parts that you need from that expanded form for now. We have a PR in the works that should make the php_fastcgi directive more configurable, slated for Caddy v2.1:

1 Like

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