Caddy: Difference between revisions
imported>Malteneuss Fix content error in introduction |
imported>Malteneuss m Add code highlighting |
||
Line 15: | Line 15: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
This snippet will let Caddy respond on http://localhost and https://localhost with a dummy text "Hello world!". When no port is mentioned on virtualhost like just | This snippet will let Caddy respond on <code>http://localhost</code> and <code>https://localhost</code> with a dummy text "Hello world!". When no port is mentioned on virtualhost like just <code>localhost</code> instead of <code>localhost:8080</code>, Caddy listens on <code>80</code> and <code>443</code> by default and redirects requests from port 80 (unsecured) to 443 (secured). | ||
==== Check used ports ==== | ==== Check used ports ==== | ||
To check if Caddy is running and listening as configured you can run netstat: | To check if Caddy is running and listening as configured you can run <code>netstat</code>: | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
Line 35: | Line 35: | ||
==== Check connection ==== | ==== Check connection ==== | ||
You can use curl to test the http(s) connections: | You can use <code>curl</code> to test the http(s) connections: | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
Line 57: | Line 57: | ||
Here you can see that Caddy automatically redirects from an unsecure http://localhost to a secure https://localhost call. | Here you can see that Caddy automatically redirects from an unsecure http://localhost to a secure https://localhost call. | ||
For local addresses like "localhost" Caddy always generates and uses a self-signed certificate, which curl correctly doesn't trust; use the | For local addresses like "localhost" Caddy always generates and uses a self-signed certificate, which curl correctly doesn't trust; use the <code>-k</code> flag to ignore that. | ||
== Typical configurations == | == Typical configurations == |