<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.nixos.org/w/index.php?action=history&amp;feed=atom&amp;title=Static_Web_Server</id>
	<title>Static Web Server - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.nixos.org/w/index.php?action=history&amp;feed=atom&amp;title=Static_Web_Server"/>
	<link rel="alternate" type="text/html" href="https://wiki.nixos.org/w/index.php?title=Static_Web_Server&amp;action=history"/>
	<updated>2026-05-20T05:48:37Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.0</generator>
	<entry>
		<id>https://wiki.nixos.org/w/index.php?title=Static_Web_Server&amp;diff=16188&amp;oldid=prev</id>
		<title>JadeTheDragon: Removed outdated information.</title>
		<link rel="alternate" type="text/html" href="https://wiki.nixos.org/w/index.php?title=Static_Web_Server&amp;diff=16188&amp;oldid=prev"/>
		<updated>2024-08-04T13:01:18Z</updated>

		<summary type="html">&lt;p&gt;Removed outdated information.&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 13:01, 4 August 2024&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot;&gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Static Web Server (SWS) is an HTTP server written in Rust with a focus on efficiently serving static files. The project website is https://static-web-server.net/&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Static Web Server (SWS) is an HTTP server written in Rust with a focus on efficiently serving static files. The project website is https://static-web-server.net/&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;There is a NixOS module &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;(currently on the unstable branch) &lt;/del&gt;that allows you to run and configure SWS. First, add the package to your systemPackages:&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;There is a NixOS module that allows you to run and configure SWS. First, add the package to your systemPackages:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;syntaxhighlight lang=nix&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;syntaxhighlight lang=nix&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;!-- diff cache key mediawiki:diff:1.41:old-12259:rev-16188:php=table --&gt;
&lt;/table&gt;</summary>
		<author><name>JadeTheDragon</name></author>
	</entry>
	<entry>
		<id>https://wiki.nixos.org/w/index.php?title=Static_Web_Server&amp;diff=12259&amp;oldid=prev</id>
		<title>Klinger at 19:07, 19 April 2024</title>
		<link rel="alternate" type="text/html" href="https://wiki.nixos.org/w/index.php?title=Static_Web_Server&amp;diff=12259&amp;oldid=prev"/>
		<updated>2024-04-19T19:07:01Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 19:07, 19 April 2024&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l119&quot;&gt;Line 119:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 119:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:Cookbook]]&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:Cookbook]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;NixOS]]&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Server&lt;/ins&gt;]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[Category:Applications&lt;/del&gt;]]&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-added&quot;&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;!-- diff cache key mediawiki:diff:1.41:old-10812:rev-12259:php=table --&gt;
&lt;/table&gt;</summary>
		<author><name>Klinger</name></author>
	</entry>
	<entry>
		<id>https://wiki.nixos.org/w/index.php?title=Static_Web_Server&amp;diff=10812&amp;oldid=prev</id>
		<title>imported&gt;Mac-chaffee: create page</title>
		<link rel="alternate" type="text/html" href="https://wiki.nixos.org/w/index.php?title=Static_Web_Server&amp;diff=10812&amp;oldid=prev"/>
		<updated>2023-07-02T01:32:51Z</updated>

		<summary type="html">&lt;p&gt;create page&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Static Web Server (SWS) is an HTTP server written in Rust with a focus on efficiently serving static files. The project website is https://static-web-server.net/&lt;br /&gt;
&lt;br /&gt;
There is a NixOS module (currently on the unstable branch) that allows you to run and configure SWS. First, add the package to your systemPackages:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=nix&amp;gt;&lt;br /&gt;
environment.systemPackages = with pkgs; [&lt;br /&gt;
  static-web-server&lt;br /&gt;
];&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here is a minimal viable configuration of SWS:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=nix&amp;gt;&lt;br /&gt;
services.static-web-server = {&lt;br /&gt;
  enable = true;&lt;br /&gt;
  root = &amp;quot;/some/path&amp;quot;;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
By default, this will start SWS on &amp;lt;code&amp;gt;[::]:8787&amp;lt;/code&amp;gt; and it will serve files from the folder &amp;lt;code&amp;gt;/some/path&amp;lt;/code&amp;gt;. Default settings can be found here: https://github.com/NixOS/nixpkgs/blob/3eb8ccf3b3922be5586a263e7d6f4f98e3acf728/nixos/modules/services/web-servers/static-web-server.nix#L9 and here: https://static-web-server.net/configuration/config-file/&lt;br /&gt;
&lt;br /&gt;
SWS will not be exposed to your network unless you also edit the firewall rules:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=nix&amp;gt;&lt;br /&gt;
networking.firewall.allowedTCPPorts = [ 8787 ];&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Advanced Configuration ==&lt;br /&gt;
&lt;br /&gt;
To change the host or port, you can use the &amp;quot;listen&amp;quot; option like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=nix&amp;gt;&lt;br /&gt;
services.static-web-server = {&lt;br /&gt;
  enable = true;&lt;br /&gt;
  listen = &amp;quot;[::]:80&amp;quot;;&lt;br /&gt;
  root = &amp;quot;/some/path&amp;quot;;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
All other options aside from &amp;quot;listen&amp;quot; and &amp;quot;root&amp;quot; can be configured via SWS&amp;#039;s [https://static-web-server.net/configuration/config-file/ TOML config file] like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=nix&amp;gt;&lt;br /&gt;
services.static-web-server = {&lt;br /&gt;
  enable = true;&lt;br /&gt;
  listen = &amp;quot;[::]:80&amp;quot;;&lt;br /&gt;
  root = &amp;quot;/some/path&amp;quot;;&lt;br /&gt;
  configuration = {&lt;br /&gt;
    general = { &lt;br /&gt;
      directory-listing = true;&lt;br /&gt;
    };&lt;br /&gt;
  };&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Any option that can be expressed in SWS&amp;#039;s TOML file can also be configured via this same &amp;quot;configuration&amp;quot; option, with the exception of &amp;quot;host&amp;quot;, &amp;quot;port&amp;quot;, (use &amp;quot;listen&amp;quot; instead) and &amp;quot;root&amp;quot; (use the &amp;quot;root&amp;quot; option instead). This is because the host, port, and root directory choice require changes to the generated systemd unit files.&lt;br /&gt;
&lt;br /&gt;
=== HTTPS ===&lt;br /&gt;
&lt;br /&gt;
NixOS includes an ACME client which will automatically request and renew TLS certificates for you. See the [[ACME]] page for more info. Here is an example of how to integrate the ACME client with SWS:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=nix&amp;gt;&lt;br /&gt;
security.acme = {&lt;br /&gt;
  acceptTerms = true;&lt;br /&gt;
  defaults.email = &amp;quot;your-email@example.com&amp;quot;;&lt;br /&gt;
  certs.&amp;quot;your-domain.example&amp;quot; = {&lt;br /&gt;
    reloadServices = [ &amp;quot;static-web-server&amp;quot; ];&lt;br /&gt;
    listenHTTP = &amp;quot;:80&amp;quot;;&lt;br /&gt;
    group = &amp;quot;www-data&amp;quot;;&lt;br /&gt;
    # EC is not supported by SWS versions before 2.16.1&lt;br /&gt;
    keyType = &amp;quot;rsa4096&amp;quot;;&lt;br /&gt;
  };&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
# Now we need to open port 80 for the ACME challenge and port 443 for SWS itself&lt;br /&gt;
networking.firewall.allowedTCPPorts = [ 80 443 ];&lt;br /&gt;
&lt;br /&gt;
# Configure SWS to use the generated TLS certs&lt;br /&gt;
services.static-web-server = {&lt;br /&gt;
  enable = true;&lt;br /&gt;
  root = &amp;quot;/some/path&amp;quot;;&lt;br /&gt;
  listen = &amp;quot;[::]:443&amp;quot;;&lt;br /&gt;
  configuration = {&lt;br /&gt;
    general = { &lt;br /&gt;
      http2 = true;&lt;br /&gt;
      # Edit the domain name in the file to match your real domain name as configured in the ACME settings&lt;br /&gt;
      http2-tls-cert = &amp;quot;/var/lib/acme/your-domain.example/fullchain.pem&amp;quot;;&lt;br /&gt;
      http2-tls-key = &amp;quot;/var/lib/acme/your-domain.example/key.pem&amp;quot;;&lt;br /&gt;
      # Info here: https://static-web-server.net/features/security-headers/&lt;br /&gt;
      # This option is only needed for versions prior to 2.18.0, after which it defaults to true&lt;br /&gt;
      security-headers = true;&lt;br /&gt;
    };&lt;br /&gt;
  };&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
# Now we need to override some things in the systemd unit files to allow access to those TLS certs, starting with creating a new Linux group:&lt;br /&gt;
users.groups.www-data = {};&lt;br /&gt;
# This strategy can be useful to override other advanced features as-needed&lt;br /&gt;
systemd.services.static-web-server.serviceConfig.SupplementaryGroups = pkgs.lib.mkForce [ &amp;quot;&amp;quot; &amp;quot;www-data&amp;quot; ];&lt;br /&gt;
# Note that &amp;quot;/some/path&amp;quot; should match your &amp;quot;root&amp;quot; option&lt;br /&gt;
systemd.services.static-web-server.serviceConfig.BindReadOnlyPaths = pkgs.lib.mkForce [&amp;quot;/some/path&amp;quot; &amp;quot;/var/lib/acme/your-domain.example&amp;quot;];&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then run &amp;lt;code&amp;gt;nixos-rebuild switch&amp;lt;/code&amp;gt;. The first time you apply this change, SWS may fail to start up if it tries to start before the initial cert is generated (the ACME client should generate a placeholder cert very quickly). If that happens, just wait a few minutes, then run &amp;lt;code&amp;gt;systemctl restart static-web-server.service&amp;lt;/code&amp;gt;. It should then be able to load the TLS certificate.&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
&lt;br /&gt;
To check the logs, use [https://www.man7.org/linux/man-pages/man1/journalctl.1.html journalctl], such as &amp;lt;code&amp;gt;journalctl -u static-web-server.service --since=&amp;quot;30 min ago&amp;quot;&amp;lt;/code&amp;gt;. You may need to increase the log level like so:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=nix&amp;gt;&lt;br /&gt;
services.static-web-server = {&lt;br /&gt;
...&lt;br /&gt;
  configuration = {&lt;br /&gt;
    general = { &lt;br /&gt;
      log-level = &amp;quot;trace&amp;quot;;&lt;br /&gt;
    };&lt;br /&gt;
  };&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Cookbook]]&lt;br /&gt;
[[Category:NixOS]]&lt;br /&gt;
[[Category:Applications]]&lt;/div&gt;</summary>
		<author><name>imported&gt;Mac-chaffee</name></author>
	</entry>
</feed>