1. My Caddy version (caddy -version
):
(devel)
2. How I run Caddy:
sudo caddy start --config caddy.conf
a. System environment:
ubuntu
b. Command:
n/a
c. Service/unit/compose file:
n/a
d. My complete Caddyfile:
{
"logging": {
"sink": {
"writer": {
"output": "file",
"filename": "/var/log/caddy/sink.log"
}
},
"logs": {
"default": {
"writer": {
"output": "file",
"filename": "/var/log/caddy/caddy.log"
},
"encoder": {
"format":"console"
},
"level": "info",
"include": [],
"exclude": []
}
}
},
"apps": {
"http": {
"servers": {
"myserver": {
"listen": [
":443"
],
"routes": [
{
"match": [
{
"host": [
"bitwarden.sethammons.com"
]
}
],
"handle": [
{
"handler": "reverse_proxy",
"transport": {
"protocol": "http",
"tls": {}
},
"upstreams": [
{
"dial": "bitwarden.sethammons.com:5443",
"max_requests": 1000
}
]
}
]
},
{
"match": [
{
"host": [
"sethammons.com", "www.sethammons.com"
]
}
],
"handle": [
{
"handler": "file_server",
"root": "/home/seth/projects/me/site/public"
}
]
},
{
"match": [
{
"host": [
"grzlybr.com"
]
}
],
"handle": [
{
"handler": "reverse_proxy",
"upstreams": [
{
"dial": "localhost:1414",
"max_requests": 1000
}
]
}
]
}
]
}
}
}
}
}
3. The problem I’m having:
I want https://www.sethammons.com to redirect to https://sethammons.com (ie, strip the www). Currently, I have it serving the www subdomain but would prefer it to redirect to not have the www.
I am not able to understand the way to do this based on the documentation. I imagine the redir handler has some way to send the given request to a different match. I just don’t grok it.
4. Error messages and/or full log output:
n/a
5. What I already tried:
I read through the docs and see there are redir and rewrite options, but I don’t see how to convert them to json and add them to my caddy file. It seems like redir is the right one, but I don’t see how to say “redir this matcher to this other matcher.”