NetBox: Difference between revisions
imported>Jeyemwey Simplify, reformat and remove postgres code |
the configuration was in my opinion a little bit confusing. i got it to work with my done changes. i dont have an ssl intern at the moment so i cant do with ssl configuration. when i have one i will update these page |
||
Line 13: | Line 13: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
===== Basic Configuration ===== | |||
==== Basic Configuration ==== | The module will automatically setup a redis instance and a PostgreSQL database.<syntaxhighlight lang="nix"> | ||
<syntaxhighlight lang="nix"> | |||
{ config, ... }: { | { config, ... }: { | ||
networking.firewall.allowedTCPPorts = [ 80 ]; | |||
networking.firewall.allowedTCPPorts = [ 80 | |||
services.netbox = { | services.netbox = { | ||
Line 31: | Line 26: | ||
services.nginx = { | services.nginx = { | ||
enable = true; | enable = true; | ||
virtualHosts.<name> = { | |||
virtualHosts. | |||
locations = { | locations = { | ||
"/" = { | "/" = { | ||
Line 43: | Line 34: | ||
"/static/" = { alias = "${config.services.netbox.dataDir}/static/"; }; | "/static/" = { alias = "${config.services.netbox.dataDir}/static/"; }; | ||
}; | }; | ||
}; | }; | ||
}; | }; | ||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=== Setup Superuser === | === Setup Superuser === |
Revision as of 22:42, 8 May 2024
NetBox is available as a module.
Setup
Setup Secret Key
Netbox uses a secret key to derive new hashes for passwords and HTTP cookies [1]. You should not share this key outside of the configuration (i.e. in /nix/store) and it must be at least 50 characters long:
mkdir -p /var/lib/netbox/
nix-shell -p openssl
openssl rand -hex 50 > /var/lib/netbox/secret-key-file
Basic Configuration
The module will automatically setup a redis instance and a PostgreSQL database.
{ config, ... }: {
networking.firewall.allowedTCPPorts = [ 80 ];
services.netbox = {
enable = true;
secretKeyFile = "/var/lib/netbox/secret-key-file";
};
services.nginx = {
enable = true;
virtualHosts.<name> = {
locations = {
"/" = {
proxyPass = "http://[::1]:8001";
# proxyPass = "http://${config.services.netbox.listenAddress}:${config.services.netbox.port}";
};
"/static/" = { alias = "${config.services.netbox.dataDir}/static/"; };
};
};
};
}
Setup Superuser
There will be no user after the installation, so you need to install one manually. To do this, run:
$ netbox-manage createsuperuser
Username (leave blank to use 'netbox'):
Email address:
Password:
Password (again):
Superuser created successfully.
You can now login with the given credentials at https://netbox.domain.tld/login/