Binary Cache: Difference between revisions
imported>Aleb mNo edit summary |
imported>Aleb Specify nix-serve limited to IPv4; nginx config sample for non-NixOS |
||
| Line 36: | Line 36: | ||
<syntaxhighlight lang="crontab"> | <syntaxhighlight lang="crontab"> | ||
NIX_SECRET_KEY_FILE=/var/cache-priv-key.pem | NIX_SECRET_KEY_FILE=/var/cache-priv-key.pem | ||
@reboot /home/USER/.nix-profile/bin/nix-serve --error-log /var/log/nix-serve.log --pid /var/run/nix-serve.pid --user USER --daemonize | @reboot /home/USER/.nix-profile/bin/nix-serve --listen :5000 --error-log /var/log/nix-serve.log --pid /var/run/nix-serve.pid --user USER --daemonize | ||
</syntaxhighlight> | </syntaxhighlight> | ||
| Line 43: | Line 43: | ||
=== 3. Creating a virtual hostname in {{ic|nginx}} === | === 3. Creating a virtual hostname in {{ic|nginx}} === | ||
We redirect the HTTP(s) traffic from port 80 to {{ic|nix-serve}}. | We redirect the HTTP(s) traffic from port 80 to {{ic|nix-serve}}. As {{ic|nix-serve}} is capable of serving only on IPv4, redirecting is also useful to make the binary cache available on IPv6. | ||
<syntaxhighlight lang="nix"> | <syntaxhighlight lang="nix"> | ||
| Line 64: | Line 64: | ||
Add HTTPS settings to this config if possible.<ref group="cf.">{{manual:nixos|sec=#module-security-acme-nginx|chapter=26.3. Using ACME certificates in Nginx}}</ref> This tutorial will simply continue with insecure HTTP. | Add HTTPS settings to this config if possible.<ref group="cf.">{{manual:nixos|sec=#module-security-acme-nginx|chapter=26.3. Using ACME certificates in Nginx}}</ref> This tutorial will simply continue with insecure HTTP. | ||
To set up Nginx on a non-NixOS machine, create for example {{ic|/etc/nginx/sites-enabled/nix-serve.conf }}: | |||
<syntaxhighlight lang="nginx"> | |||
server { | |||
listen 80 default_server; | |||
listen [::]:80 default_server; | |||
location / { | |||
proxy_pass http://127.0.0.1:5000; | |||
} | |||
} | |||
</syntaxhighlight> | |||
=== 4. Rebuilding and testing === | === 4. Rebuilding and testing === | ||