Jump to content

Caddy: Difference between revisions

603 bytes added ,  8 July 2023
Simplify installation example
imported>Malteneuss
m (Fix table layout)
imported>Malteneuss
(Simplify installation example)
Line 1: Line 1:
[https://caddyserver.com/ Caddy] is a HTTP/2 capable web server with automatic HTTPS.
[https://caddyserver.com/ Caddy] is an efficient, HTTP/2 capable web server that can serve static and dynamic web pages.
It can also be a reverse proxy to serve multiple web services under one server. Its main features are its simple config setup and automatic HTTPS: It will automatically request and renew a LetsEncrypt certificate so that users of your service get a Browser-trusted and secure connection.


== Installation ==
== Installation ==


The example snippet below will run Caddy on http://localhost and serving an [http://localhost/example.html example.html] page.
To try out Caddy add the following minimal example to your NixOS module:


<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
services.caddy = {
services.caddy = {
   enable = true;
   enable = true;
   extraConfig = ''
   virtualHosts."localhost:80".extraConfig = ''
     http://localhost {
     respond "Hello, world!"
      encode gzip
  '';
      file_server
}; 
      root * ${
</syntaxhighlight>
        pkgs.runCommand "testdir" {} ''
 
          mkdir "$out"
The snippet above will run Caddy on http://localhost and respond with a dummy text "Hello world!".
          echo hello world > "$out/example.html"
 
        ''
A similar example with serving a dummy "http://localhost/example.html" page is:
      }
 
<syntaxhighlight lang="nix">
services.caddy = {
  enable = true;
  virtualHosts."localhost".extraConfig = ''
    encode gzip
    file_server
    root * ${
      pkgs.runCommand "testdir" {} ''
        mkdir "$out"
        echo hello world > "$out/example.html"
      ''
     }
     }
   '';
   '';
};
};
</syntaxhighlight>
</syntaxhighlight>


Anonymous user