1. The problem I’m having:
Using www on my domain didn’t work and I fixed that.
However I have serious doubts about my approach and I wondered if someone can have a look. If somone does not specify www then I still wan’t it to go to the www version.
2. Error messages and/or full log output:
No errors…
3. Caddy version:
v2.7.6 h1:w0NymbG2m9PcvKWsrXO6EEkY9Ru4FJK8uQbYcev1p3A=
4. How I installed and ran Caddy:
I can’t remember how I installed.
curl localhost:2019/load -H "Content-Type: application/json" -d @/home/doeke/Desktop/_DONT_MOVE_THIS_FOLDER_OR_ANYTHING_IN_IT_/caddy.json
a. System environment:
Ubuntu 22.04.3 LTS
b. Command:
curl localhost:2019/load -H "Content-Type: application/json" -d @/home/doeke/Desktop/_DONT_MOVE_THIS_FOLDER_OR_ANYTHING_IN_IT_/caddy.json
Important note!!!
I can set a subdomain with my DNS settings on my hosting. I set them to www now, I didn’t have that before. It might take some time to get into effect.
Hope someone can help.
(and yeah maybe I should switch to using Caddyfile…).
{
"apps": {
"http": {
"servers": {
"=== HSLAB === & === DOEKE_WARTENA ===": {
"listen": [":443"],
"routes": [
{
"match":
[ {"host": ["hslab.nl", "doekewartena.nl", "nc.doekewartena.nl"]} ],
"handle": [
{
"handler": "static_response",
"headers": {
"Location": [
"http://www.{http.request.host}{url}"
]
},
"status_code": 302
}
],
"terminal": true
},
{
"match":
[ {"host": ["www.hslab.nl"]} ],
"handle": [
{
"handler": "static_response",
"body": "hslab"
}
],
"terminal": true
},
{
"match": [
{
"host": ["www.doekewartena.nl"]
}
],
"handle": [
{
"handler": "static_response",
"body": "doekewartena"
}
],
"terminal": true
},
{
"match": [
{
"host": ["www.nc.doekewartena.nl"]
}
],
"handle": [
{
"handler": "reverse_proxy",
"upstreams": [
{
"dial": "localhost:81"
}
]
}
],
"terminal": true
}
]
}
}
}
}
}