Trying to run localhost https with mutiple sites

1. The problem I’m having:

I can get a config file setup to run one https site in my local domain but not able to configure a file to run two or more.

This works (one website) Caddyfile:

https://192.168.0.23 {
    root * c:\dev\vue-quasar-app\Frontend\dist
    file_server
    tls internal
}

This does not work (two websites) Caddyfile:

https://192.168.0.23 {
    tls internal

    @pwa path /pwa/*
    handle @pwa {
    root * C:\dev\QuasarCliVite\dist\pwa
        file_server
    }

    @quasarapp path /quasarapp
    handle @quasarapp {
    root * c:\dev\vue-quasar-app\Frontend\dist
        file_server
    }
}

2. Error messages and/or full log output:

https://192.168.0.23/quasarapp

Error: 404 cannot be found, does not resolve to the website. 

3. Caddy version:

4. How I installed and ran Caddy:

I just copied the exe to c:\dev\caddy sub dir. Then run via windows cmd prompt:

a. System environment:

running windows 11 Version 24H2

b. Command:

C:\dev\caddy>caddy_windows_amd64 run --config Caddyfile

c. Service/unit/compose file:

N/A

d. My complete Caddy config:

https://192.168.0.231 {
    tls internal

    @pwa path /pwa/*
    handle @pwa {
    root * C:\dev\QuasarCliVite\dist\pwa
        file_server
    }

    @quasarapp path /quasarapp
    handle @quasarapp {
    root * c:\dev\vue-quasar-app\Frontend\dist
        file_server
    }
}

5. Links to relevant resources:

This does work for a caddy file. However, it’s only one web site. I would like to run multiple.

https://192.168.0.231 {
    root * c:\dev\vue-quasar-app\Frontend\dist
    file_server
    tls internal
}

I cannot replicate. Are you sure the path has an index file?

One is dist\pwa\index.html, the other is Frontend\dist\index.html. If you are up for reproducing, I added the dist to the repositories on github. You can check them out here:

https://github.com/billjenner/QuasarCliVite

Bill

Your app requires mongodb and whtanot. I don’t have these prerequisites handy. At a glance, I see your matcher doesn’t have wildcard * at the end, which means it’ll only match and handle /quasarapp, but nothing under /quasarapp/assets*.

Also, your app has to know that it’s served on a sub-path.

Lastly, it’s not clear if the shared log is from the browser or your own app or something else.

I’ve tried it multiple ways, with an asterisk, without an asterisk. At this point, I’m wondering if the windows version even works with handle or handle_path. I can’t get it to work.

You have to share more and better logs. Share some Caddy logs. Clarify where the already shared logs are from.

URL

https://192.168.0.23/pwa

Caddyfile

https://192.168.0.23 {
	tls internal

    handle_path /pwa/* {
		root * C:\dev\QuasarCliVite\dist\pwa
        file_server
    }

	log {
		level DEBUG
	}
}

Log

{
    "request": {
        "remote_ip": "192.168.0.23",
        "remote_port": "52006",
        "client_ip": "192.168.0.23",
        "proto": "HTTP/2.0",
        "method": "GET",
        "host": "192.168.0.23",
        "uri": "/pwa",
        "headers": {
            "Upgrade-Insecure-Requests": [
                "1"
            ],
            "Accept-Language": [
                "en-US,en;q=0.9,da;q=0.8"
            ],
            "Sec-Gpc": [
                "1"
            ],
            "Sec-Ch-Ua": [
                "\"Chromium\";v=\"136\", \"Google Chrome\";v=\"136\", \"Not.A/Brand\";v=\"99\""
            ],
            "User-Agent": [
                "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36"
            ],
            "Accept": [
                "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7"
            ],
            "Sec-Fetch-Site": [
                "none"
            ],
            "Sec-Ch-Ua-Mobile": [
                "?0"
            ],
            "Sec-Fetch-Dest": [
                "document"
            ],
            "Priority": [
                "u=0, i"
            ],
            "Sec-Ch-Ua-Platform": [
                "\"Windows\""
            ],
            "Sec-Fetch-Mode": [
                "navigate"
            ],
            "Sec-Fetch-User": [
                "?1"
            ],
            "Accept-Encoding": [
                "gzip, deflate, br, zstd"
            ]
        },
        "tls": {
            "resumed": false,
            "version": 772,
            "cipher_suite": 4865,
            "proto": "h2",
            "server_name": ""
        }
    },
    "bytes_read": 0,
    "user_id": "",
    "duration": 0,
    "size": 0,
    "status": 0,
    "resp_headers": {
        "Alt-Svc": [
            "h3=\":443\"; ma=2592000"
        ],
        "Server": [
            "Caddy"
        ]
    }
}

You’re requesting /pwa, but configured caddy with /pwa/*, so the last slash must exist per your configuration.

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