mirror of
https://github.com/caddyserver/caddy.git
synced 2025-07-09 03:04:57 -04:00
Updated Writing a Plugin: Server Type (markdown)
parent
f779535543
commit
b129f5b866
@ -92,7 +92,7 @@ Server types that _can_ use TLS should enable TLS automatically before we add it
|
||||
- Call [`RegisterConfigGetter()`](https://godoc.org/github.com/mholt/caddy/caddytls#RegisterConfigGetter) in your package's init() so that the caddytls package knows how to ask for a config when it is parsing the Caddyfile for your server type. (Your "config getter" will have to make a new `caddytls.Config` if one does not already exist for the given Controller.)
|
||||
- Add the `tls` directive to your server type's list of directives. Usually it goes near the front of the list.
|
||||
|
||||
When you are instantiating your actual server value and need a [`tls.Config`](https://golang.org/pkg/crypto/tls/#Config), you can call `caddytls.MakeTLSConfig(tlsConfigs)` where `tlsConfigs` is a `[]caddytls.Config`. This function will convert a list of Caddy TLS configs to a single standard library tls.Config for you. You can then use this in a call to [`tls.NewListener()`](https://golang.org/pkg/crypto/tls/#NewListener).
|
||||
When you are instantiating your actual server value and need a [`tls.Config`](https://golang.org/pkg/crypto/tls/#Config), you can call [`caddytls.MakeTLSConfig(tlsConfigs)`](https://godoc.org/github.com/mholt/caddy/caddytls#MakeTLSConfig) where `tlsConfigs` is a `[]caddytls.Config`. This function will convert a list of Caddy TLS configs to a single standard library tls.Config for you. You can then use this in a call to [`tls.NewListener()`](https://golang.org/pkg/crypto/tls/#NewListener).
|
||||
|
||||
Finally, you typically want to enable TLS while the Caddyfile is being parsed. For example, the HTTP server configures HTTPS right after the `tls` directive is executed. You should use your package's `init()` function to register a parsing callback that goes through the configurations and configures TLS:
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user