Traefik: Difference between revisions
m rewording |
m moved a closing bracket in the config example, previous example does not build because "log" and "certificateResolvers" are listed under "entryPoints", rather than "staticConigOptions" |
||
(5 intermediate revisions by 2 users not shown) | |||
Line 8: | Line 8: | ||
== Configuration == | == Configuration == | ||
==== Using | ==== Using Nix ==== | ||
<syntaxhighlight lang="nixos"> | <syntaxhighlight lang="nixos"> | ||
services.traefik = { | services.traefik = { | ||
Line 29: | Line 29: | ||
http.tls.certResolver = "letsencrypt"; | http.tls.certResolver = "letsencrypt"; | ||
}; | }; | ||
}; | |||
log = { | |||
level = "INFO"; | |||
filePath = "${config.services.traefik.dataDir}/traefik.log"; | |||
format = "json"; | |||
}; | |||
certificatesResolvers.letsencrypt.acme = { | |||
email = "postmaster@YOUR.DOMAIN"; | |||
storage = "${config.services.traefik.dataDir}/acme.json"; | |||
httpChallenge.entryPoint = "web"; | |||
}; | }; | ||
Line 55: | Line 55: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
==== Using files ==== | ==== Using non-Nix configuration files ==== | ||
If you are migrating from a Non-NixOS system, you might be interested in the <code>staticConfigFile</code> and <code>dynamicConfigFile</code> options. | If you are migrating from a Non-NixOS system, you might be interested in the <code>staticConfigFile</code> and <code>dynamicConfigFile</code> options. | ||
You can set <code>staticConfigFile</code> like this:<syntaxhighlight lang="nixos"> | You can set <code>staticConfigFile</code> like this:<syntaxhighlight lang="nixos"> | ||
services.traefik.staticConfigFile = ./static_config.toml; | services.traefik.staticConfigFile = ./static_config.toml; | ||
</syntaxhighlight>But you need to be careful about how you set the <code>services.traefik.dynamicConfigFile</code> option, if you use a path like shown above, your file will end up in the [[Nix store]], | </syntaxhighlight>But you need to be careful about how you set the <code>services.traefik.dynamicConfigFile</code> option, if you use a path like shown above, your file will end up in the [[Nix store]], and it will change every time you update your configuration, which means Traefik won't be able to reload with your changes automatically, which defeats the point of using the dynamic config file. | ||
A way to avoid this is to use <code>etc.environment</code>:<syntaxhighlight lang="nixos"> | A way to avoid this is to use <code>etc.environment</code>:<syntaxhighlight lang="nixos"> | ||
Line 79: | Line 79: | ||
}; | }; | ||
</syntaxhighlight>Additionally, you can not use a <code>...ConfigFile</code> option and a <code>...ConfigOptions</code> for either static or dynamic configuration. The file options always take precedence over the options options, which are ignored. | </syntaxhighlight>Additionally, you can not use a <code>...ConfigFile</code> option and a <code>...ConfigOptions</code> for either static or dynamic configuration. The file options always take precedence over the options options, which are ignored. | ||
[[Category:Applications]] | |||
[[Category:Server]] | |||
[[Category:Networking]] |