Not serving page other than /

1. Caddy version (caddy version):

v2.3.0 h1:fnrqJLa3G5vfxcxmOH/+kJOcunPLhSBnjgIvjXV/QTA=

2. How I run Caddy:

caddy run

a. System environment:

Docker-compose

b. Command:

docker-compose up caddy

c. Service/unit/compose file:

version: "3.3"
services:
  redis:
    image: redis:alpine
    networks:
      - shared
  mongo:
    image: mongo:4.2.11
    volumes:
      - mongodata:/data/db
    ports:
      - 127.0.0.1:${VUE_APP_MONGODB_PORT}:27017
    networks:
      - shared
  server:
    image: nertivia/server-caddy
    env_file: .env
    networks:
      - shared
  client:
    image: nertivia/client-caddy
    env_file: .env
    networks:
      - shared
  caddy:
    image: caddy:alpine
    env_file: .env
    volumes:
      - ./cdn/Caddyfile:/etc/caddy/Caddyfile
      - ./cdn/public_html:/srv
      - ./cdn/ssl_certs:/root/.caddy
    ports:
      - 80:80
      - 443:443
    networks:
      - shared
  php:
    image: php:fpm-alpine
    working_dir: /srv
    env_file: .env
    volumes:
      - ./cdn/public_html:/srv
    networks:
      - shared
  image-server:
    image: node:lts-alpine
    working_dir: /srv/node
    command: sh -c "npm i && node app.js"
    volumes:
      - ./cdn/public_html:/srv
    env_file: .env
    networks:
      - shared
volumes:
  mongodata:
networks:
  shared:

d. My complete Caddyfile or JSON config:

https://localtest.me {
        tls /root/.caddy/localtest.me+1.pem /root/.caddy/localtest.me+1-key.pem
        reverse_proxy client:8080
}

https://server.localtest.me {
        tls /root/.caddy/localtest.me+1.pem /root/.caddy/localtest.me+1-key.pem
        reverse_proxy server:8181
}

https://cdn.localtest.me {
        tls /root/.caddy/localtest.me+1.pem /root/.caddy/localtest.me+1-key.pem
        encode gzip
        php_fastcgi php:9000
        file_server
}

3. The problem I’m having:

4. Error messages and/or full log output:

Starting caddy_caddy_1 ... done
Attaching to caddy_caddy_1
caddy_1         | {"level":"info","ts":1610901064.9383345,"msg":"using provided configuration","config_file":"/etc/caddy/Caddyfile","config_adapter":"caddyfile"}
caddy_1         | {"level":"info","ts":1610901064.9404683,"logger":"admin","msg":"admin endpoint started","address":"tcp/localhost:2019","enforce_origin":false,"origins":["localhost:2019","[::1]:2019","127.0.0.1:2019"]}
caddy_1         | {"level":"info","ts":1610901064.9408333,"logger":"tls.cache.maintenance","msg":"started background certificate maintenance","cache":"0xc000449ea0"}
caddy_1         | {"level":"warn","ts":1610901064.9440534,"logger":"tls","msg":"stapling OCSP","error":"no OCSP stapling for [localtest.me *.localtest.me]: no OCSP server specified in certificate"}
caddy_1         | {"level":"info","ts":1610901064.9442084,"logger":"http","msg":"skipping automatic certificate management because one or more matching certificates are already loaded","domain":"server.localtest.me","server_name":"srv0"}
caddy_1         | {"level":"info","ts":1610901064.9442265,"logger":"http","msg":"skipping automatic certificate management because one or more matching certificates are already loaded","domain":"cdn.localtest.me","server_name":"srv0"}
caddy_1         | {"level":"info","ts":1610901064.9442306,"logger":"http","msg":"skipping automatic certificate management because one or more matching certificates are already loaded","domain":"localtest.me","server_name":"srv0"}
caddy_1         | {"level":"info","ts":1610901064.9442337,"logger":"http","msg":"enabling automatic HTTP->HTTPS redirects","server_name":"srv0"}
caddy_1         | {"level":"info","ts":1610901064.9452515,"logger":"tls","msg":"cleaned up storage units"}
caddy_1         | {"level":"info","ts":1610901064.945343,"msg":"autosaved config","file":"/config/caddy/autosave.json"}
caddy_1         | {"level":"info","ts":1610901064.9453528,"msg":"serving initial configuration"}

5. What I already tried:

There must be some mistake, sections 3 and 5 were left empty.

1 Like

The volumes here aren’t quite right, you should persist the /data directory to avoid issues. It’s not safe to run Caddy without persisting that directory.

And yeah, I second @matt’s comment, there’s sections of the thread template missing, so I don’t understand the question or what’s the problem. What behaviour are you seeing for what requests?

Just a blank page on routes other than / so / is working but /test.html is not

What do you mean by “not working”? What behaviour are you seeing exactly? You’re not being specific enough.

Be aware that you can add the debug global option (at the top of your Caddyfile) and add the log directive (inside your site blocks) to see more information in your logs.

1 Like

Yeah, we’ll need the help template fully filled out. I know, a few lines of text is a lot to ask. But we need to be able to reproduce the behavior you’re seeing so we can help you fix it.

Now it works, the problem was / at the end of url (https://cdn.localtest.me/), I’ve replaced it to https://cdn.localtest.me (notice the / missing at the end) and it is working!

1 Like

Great, thanks for following up to help others.

Although, I’m confused since that does not appear tlin your config based on what you posted above.

I just forgot to put it there while replacing variables to urls

1 Like

Ah… this is why it’s a forum rule that configs are not changed like this. Next time, please follow the instructions. Thank you again for posting the solution.

2 Likes

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