Hello, this config just works fine with https only. Now I also want to open port 80, and enable redirection to https. Is this possible with the Caddyfile? I already tried many things, but nothing is working. When i add :80 below the tls options, I get the error:
2020/04/24 07:49:41.243 INFO using adjacent Caddyfile
run: adapting config using caddyfile: cannot make a TLS automation policy from a server block that has a host-less address when there are other server block addresses lacking a host
Thanks for the quick reaction!
Unfortunately it is not working.
This WARN message is shown in the log
2020/04/28 09:19:57.896 WARN http user server is listening on same interface as automatic HTTP->HTTPS redirects; user-configured routes might override these redirects {"server_name": "srv0", "interface": "tcp/:80"}
I build caddy from master and the config json is the same as shown above.
@spn Is that really your full Caddyfile? Please provide your full and unredacted config so I can investigate. Edit: oh, so wait, are you not using the Caddyfile anymore?
Edit 2: your json defines routes for port 80 that don’t redirect, so obviously it will overwrite caddy’s implicit redirects. Do you want requests on port 80 to be proxied or to redirect?
If you want them to redirect please try with your original Caddyfile or remove the routes on port 80 in your JSON.
@matt yes, this is my full Caddyfile, but I was not able to listen on port 80 and 443 as described in my first post. I thought this is a limitation of the Caddyfile and created the json config. Should this also work with the Caddyfile?
I have removed port 80 from the json config and now also the redirect to https is working. Thank you!