so he/she needs to go with tls internal
So to use tls for testing purpose, I need to manually generate keys and add to Caddyfile as mentioned in the syntax:
tls [internal|<email>] | [<cert_file> <key_file>] {
protocols <min> [<max>]
ciphers <cipher_suites...>
curves <curves...>
alpn <values...>
load <paths...>
ca <ca_dir_url>
ca_root <pem_file>
dns <provider_name> [<params...>]
on_demand
}
No; look at the examples at the bottom.
Please let me know if it’s the correct syntax of defining tls
testhost.com {
tls internal
respond "Hello, world!"
}
I tried above in Caddyfile but can’t make it work.
2020/05/08 17:54:47.032 INFO using adjacent Caddyfile
2020/05/08 17:54:47.035 INFO admin admin endpoint started {"address": "tcp/localhost:2019", "enforce_origin": false, "origins": ["localhost:2019", "[::1]:2019", "127.0.0.1:2019"]}
2020/05/08 23:39:47 [INFO][cache:0xc0004f18b0] Started certificate maintenance routine
2020/05/08 17:54:47.045 INFO http enabling automatic HTTP->HTTPS redirects {"server_name": "srv0"}
2020/05/08 17:54:47.227 INFO pki.ca.local root certificate is already trusted by system {"path": "storage:pki/authorities/local/root.crt"}
2020/05/08 17:54:47.228 INFO tls cleaned up storage units
2020/05/08 17:54:47.228 INFO http enabling automatic TLS certificate management {"domains": ["testhost.com"]}
2020/05/08 23:39:47 [WARNING] Stapling OCSP: no OCSP stapling for [testhost.com]: no OCSP server specified in certificate
2020/05/08 17:54:47.229 INFO autosaved config {"file": "/Users/sujit/Library/Application Support/Caddy/autosave.json"}
2020/05/08 17:54:47.229 INFO serving initial configuration
Successfully started Caddy (pid=32779) - Caddy is running in the background
Service started but the URL is not accessible via:
https://testhost.com
https://testhost.com:443
I can only make it work with localhost:
localhost {
tls internal
respond "Hello, world!"
}
I needed to add to hosts to make it work.
Thanks all! now it seems to work as expected.
Can we make the domain work without adding to hosts file?
hosts file edits are required to override DNS for the test domains. Only way.
There is an alternative: Split DNS (i.e. run your own DNS resolver inside your LAN that points arbitrary hostnames to your dev server).
Whether you edit your hosts file or your local DNS resolver, though, you will have to add those hostnames manually somewhere.
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.