Reputation: 5205
I have a server running Caddy
that can be reached under the domain rv2680.1blu.de
and marleneschulz.info
. Both DNS A records point to the IP address 178.254.7.175
. I want to make sure Caddy
always redirects the user to https://marleneschulz.info
.
Here is my working Caddyfile
:
www.marleneschulz.info {
redir https://marleneschulz.info
}
https://marleneschulz.info {
root /app/marlene/shared
proxy / django_prod:5000 {
header_upstream Host {host}
header_upstream X-Real-IP {remote}
header_upstream X-Forwarded-Proto {scheme}
except /static
}
log stdout
errors stdout
gzip
}
How can I prevent Caddy
responding with e.g. 404 Site rv2680.1blu.de is not served on this interface
by explicitly defining to redirect every request from rv2680.1blu.de:80
, rv2680.1blu.de:443
, 178.254.7.175:80
, 178.254.7.175:443
and marleneschulz.info
to https://marleneschulz.info
?
I am also a bit confused since the docs state nothing about the www.
prefix.
I want to be as explicit as possible.
Upvotes: 2
Views: 2030
Reputation: 23759
You can define a couple catch-all sites and redirect them:
http://, https:// {
redir https://marleneschulz.info{uri}
}
(I added {uri}
because I assume you want to preserve the URI in the redirect.)
Using http://, https://
as site addresses is the same as using :80, :443
.
There's nothing special about the www
prefix, either. If you wanted to enumerate all the sites you want to redirect, you would specify www.marleneschulz.info
as one of them, just as with any other sites.
Upvotes: 3