Basic V2 static site doesn't load content [solved]

1. Caddy version (caddy version):

caddy_2.1.1_linux_amd64.tar.gz

2. How I run Caddy:

systemd service

a. System environment:

ArchLinux at Linode

b. Command:

mkdir /var/lib/caddy /etc/caddy /var/www

groupadd --system caddy
usermod -a -G caddy [server admin user]
useradd --system -M -b /var/lib/caddy -s /usr/sbin/nologin -g caddy caddy

(service file)
(caddy file)

chown -R caddy:caddy /var/lib/caddy /etc/caddy /var/www
chmod -R 770 /etc/caddy /var/www
chmod -R 777 /var/lib/caddy

systemctl daemon-reload
systemctl enable caddy.service
systemctl start caddy.service
systemctl status caddy.service
journalctl -u caddy.service

c. Service/unit/compose file:

[Unit]
Description=Caddy
Documentation=https://caddyserver.com/docs/
After=network.target

[Service]
User=caddy
Group=caddy
ExecStart=/usr/bin/caddy run --environ --config /etc/caddy/Caddyfile
ExecReload=/usr/bin/caddy reload --config /etc/caddy/Caddyfile
TimeoutStopSec=5s
LimitNOFILE=1048576
LimitNPROC=512
PrivateTmp=true
ProtectSystem=full
AmbientCapabilities=CAP_NET_BIND_SERVICE

[Install]
WantedBy=multi-user.target

d. My complete Caddyfile or JSON config:

{
    admin off
    email name@email.com
    key_type rsa4096
}

projectencode.com, www.projectencode.com {
    root * /var/www/project
}

3. The problem I’m having:

Caddy starts, and receives a TLS cert. The only file under /var/www/project is index.html which contains “hello world” … but when I visit (or cURL) https://projectencode.com the contents of the file do not load, only a blank page.

4. Error messages and/or full log output:

â—Ź caddy.service - Caddy
     Loaded: loaded (/etc/systemd/system/caddy.service; enabled; vendor preset: disabled)
     Active: active (running) since Sat 2020-07-11 16:07:02 UTC; 19min ago
       Docs: https://caddyserver.com/docs/
   Main PID: 479 (caddy)
      Tasks: 6 (limit: 1157)
     Memory: 9.1M
     CGroup: /system.slice/caddy.service
             └─479 /usr/bin/caddy run --environ --config /etc/caddy/Caddyfile

Jul 11 16:07:02 localhost caddy[479]: {"level":"info","ts":1594483622.670711,"msg":"using provided configuration","config_file":"/etc/caddy/Caddyfile","config_adapter":""}
Jul 11 16:07:02 localhost caddy[479]: {"level":"warn","ts":1594483622.6726253,"logger":"admin","msg":"admin endpoint disabled"}
Jul 11 16:07:02 localhost caddy[479]: {"level":"info","ts":1594483622.673202,"logger":"http","msg":"server is listening only on the HTTPS port but has no TLS connection policies; adding one to enable TLS","server_name":"sr>
Jul 11 16:07:02 localhost caddy[479]: {"level":"info","ts":1594483622.673314,"logger":"http","msg":"enabling automatic HTTP->HTTPS redirects","server_name":"srv0"}
Jul 11 16:07:02 localhost caddy[479]: {"level":"info","ts":1594483622.6749682,"logger":"tls","msg":"cleaned up storage units"}
Jul 11 16:07:02 localhost caddy[479]: {"level":"info","ts":1594483622.6755164,"logger":"http","msg":"enabling automatic TLS certificate management","domains":["projectencode.com","www.projectencode.com"]}
Jul 11 16:07:02 localhost caddy[479]: {"level":"info","ts":1594483622.6777062,"msg":"autosaved config","file":"/var/lib/caddy/caddy/.config/caddy/autosave.json"}
Jul 11 16:07:02 localhost caddy[479]: {"level":"info","ts":1594483622.6778152,"msg":"serving initial configuration"}
Jul 11 16:07:02 localhost caddy[479]: 2020/07/11 16:07:02 [INFO][cache:0xc00048de60] Started certificate maintenance routine

5. What I already tried:

I checked the following, and rebooted:

  • caddy user and group, following official documentation
  • permissions of folders and files

6. Links to relevant resources:

Unknown

Welcome Mike,

Have you tried our getting started guide? I highly recommend starting with that. You might also like our Common Patterns for the Caddyfile:

That should reveal to you that your config is missing something very important. (Hint: So far, you haven’t told it to actually do anything to respond to requests…)

Oh! I mistook the “file_server” directive as the equivalent to V1’s “http.browse” and ignored it. Thank you!

1 Like

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