Caddy.Config (Caddy v2.0.7)
View SourceStart Caddy Config process to manage Caddy configuration.
Configuration is stored in %Caddy.Config{}
struct in Caddy.Config
process.
%Caddy.Config{
bin: binary() | nil,
global: binary(),
additional: [binary()],
sites: map(),
env: list({binary(), binary()})
}
Summary
Functions
Convert caddyfile to json format.
Returns a specification to start this module under a supervisor.
Get the :key in Caddy Cofnig
Return the current configuration in Caddy.Config
Callback implementation for GenServer.init/1
.
Set the Caddy binary path
Set the caddy binary path and restart Caddy.Server
Replace the current configuration in Caddy.Config
Set the global configuration
Set the site configuration
Confirt %Caddy.Config{}
to caddyfile()
Types
Functions
Convert caddyfile to json format.
Returns a specification to start this module under a supervisor.
See Supervisor
.
Get the :key in Caddy Cofnig
@spec get_config() :: t()
Return the current configuration in Caddy.Config
@spec init(keyword()) :: {:ok, %Caddy.Config{ additional: term(), bin: term(), env: term(), global: term(), sites: term() }}
Callback implementation for GenServer.init/1
.
Set the Caddy binary path
Set the caddy binary path and restart Caddy.Server
Replace the current configuration in Caddy.Config
Set the global configuration
Caddy.Config.set_global("""
debug
auto_https off
""")
@spec set_site(site_name(), site_config()) :: {:ok, site_name(), site_config()} | {:error, term()}
Set the site configuration
Caddy.Config.set_site("www.gsmlg.com", """
reverse_proxy {
to localhost:4000
header_up host www.gsmlg.com
header_up X-Real-IP {remote_host}
}
""")
# or
Caddy.Config.set_site("proxy", {":8080", """
reverse_proxy {
to localhost:3128
}
"""})
Confirt %Caddy.Config{}
to caddyfile()
See System.user_home/0
.