Newbie to Caddy here, just kicking the tyres [I currently use Nginx on all my sites]. Could someone show me the recommended Caddy way for redirecting from www.domain.com to domain.com. I can’t find any examples of this in the docs.
OK. Cancel that drivel underneath. It’s sorted now.
I was using Opera before. I’ve just tried in Chrome and it works perfectly. I don’t know WTF is going on in Opera’s tiny mind, with all that lunatic recursive redirecting.
Must have been something like that. Don’t know if you saw my original post before I deleted it, but navigating to either www.domain.com or domain.com, Opera was trying to load:
My site has been running on caddy for months and today started acting weird in a number of browsers; the issue was reported to me by one of the site users first. Out of the blue, I didn’t change anything and now I’ve been fighting it all day.
I do the opposite of you, domain.com to www.domain.com & I’m frustrated to the point of not being able to think straight; any help is appreciated.
I was only seeing that recursive redirection in Opera. All other browsers were behaving as expected. I “solved” [for tenuous definitions of “solved”] the problem by clearing Opera’s caches.
However, I was in the process of actually tinkering with my Caddyfile at the time, so that kinda makes things breaking to be expected. It seems even more puzzling that you suddenly started seeing this happen, without having touched anything in your setup.
I’m pretty swamped with research for the next few days; if anyone would like to take a look in the code in the meantime, redirect.go would be the file to start in.
I’m also new to Caddy and am just setting it up and ran into the same issue which I resolved follows:
# Setup vhost for domain.com and www.domain.com
domain.com, www.domain.com {
root /home/domain/public_html/
}
You also need to setup a Domain Pointer for www.domain.com I use Digital Ocean and this is a matter of adding the www entry using Networking | Domains. Otherwise when you start caddy you will get the error:
Activating privacy features...2016/12/14 23:51:58 [www.domain.com] failed to get certificate: acme: Error 400 - urn:acme:error:connection - DNS problem: NXDOMAIN looking up A for www.domain.com
You can check that the Domain Pointer is set as follows:
$ dig +short A domain_name
which will display the server’s IP address. You need to do this for www.domain.com and domain.com