NetBox: Difference between revisions
imported>Vater mNo edit summary |
imported>Jeyemwey Simplify, reformat and remove postgres code |
||
Line 1: | Line 1: | ||
[https://netbox.dev/ {{PAGENAME}}] | [https://netbox.dev/ {{PAGENAME}}] is available as a [[module]]. | ||
== | == Setup == | ||
==== | ==== Setup Secret Key ==== | ||
Netbox uses a secret key to derive new hashes for passwords and HTTP cookies [https://docs.netbox.dev/en/stable/configuration/required-parameters/#secret_key]. | |||
You should not share this key outside of the configuration (i.e. in /nix/store) and it must be at least 50 characters long: | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
mkdir -p /var/lib/netbox/ | |||
nix-shell -p openssl | |||
openssl rand -hex 50 > /var/lib/netbox/secret-key-file | |||
</syntaxhighlight> | </syntaxhighlight> | ||
==== Basic Configuration ==== | |||
<syntaxhighlight lang="nix"> | <syntaxhighlight lang="nix"> | ||
{ config, ... }: { | |||
system.stateVersion = "24.05"; | |||
networking.hostName = "netbox"; | |||
networking.domain = "domain.tld"; | |||
networking.firewall.allowedTCPPorts = [ 80 443 ]; | |||
services.netbox = { | |||
enable = true; | |||
secretKeyFile = "/var/lib/netbox/secret-key-file"; | |||
}; | |||
services.nginx = { | |||
enable = true; | |||
user = "netbox"; | |||
recommendedTlsSettings = true; | |||
clientMaxBodySize = "25m"; | |||
virtualHosts."${config.networking.fqdn}" = { | |||
locations = { | |||
"/" = { | |||
proxyPass = "http://[::1]:8001"; | |||
# proxyPass = "http://${config.services.netbox.listenAddress}:${config.services.netbox.port}"; | |||
}; | |||
"/static/" = { alias = "${config.services.netbox.dataDir}/static/"; }; | |||
# | |||
}; | }; | ||
forceSSL = true; | |||
enableACME = true; | |||
serverName = "${config.networking.fqdn}"; | |||
}; | }; | ||
}; | }; | ||
security.acme = { | |||
defaults.email = "acme@${config.networking.domain}"; | |||
acceptTerms = true; | |||
}; | |||
} | |||
</syntaxhighlight> | </syntaxhighlight> | ||
https://netbox.domain.tld | The module will automatically setup a redis instance and a PostgreSQL database. Your [[{{PAGENAME}}]] instance is now available at: https://netbox.domain.tld | ||
<!-- | <!-- | ||
Line 120: | Line 89: | ||
--> | --> | ||
== | === Setup Superuser === | ||
== | |||
There will be no user after the installation, so you need to install one manually. | |||
To do this, run: | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
$ netbox-manage createsuperuser | |||
Username (leave blank to use 'netbox'): | Username (leave blank to use 'netbox'): | ||
Email address: | Email address: | ||
Password: | Password: | ||
Password (again): | Password (again): | ||
Superuser created successfully. | Superuser created successfully. | ||
</syntaxhighlight> | </syntaxhighlight> | ||
https://netbox.domain.tld/login/ | You can now login with the given credentials at https://netbox.domain.tld/login/ | ||
== | == Documentation == | ||
* https://netbox.dev/ | * https://netbox.dev/ |
Revision as of 18:51, 15 February 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
{ config, ... }: {
system.stateVersion = "24.05";
networking.hostName = "netbox";
networking.domain = "domain.tld";
networking.firewall.allowedTCPPorts = [ 80 443 ];
services.netbox = {
enable = true;
secretKeyFile = "/var/lib/netbox/secret-key-file";
};
services.nginx = {
enable = true;
user = "netbox";
recommendedTlsSettings = true;
clientMaxBodySize = "25m";
virtualHosts."${config.networking.fqdn}" = {
locations = {
"/" = {
proxyPass = "http://[::1]:8001";
# proxyPass = "http://${config.services.netbox.listenAddress}:${config.services.netbox.port}";
};
"/static/" = { alias = "${config.services.netbox.dataDir}/static/"; };
};
forceSSL = true;
enableACME = true;
serverName = "${config.networking.fqdn}";
};
};
security.acme = {
defaults.email = "acme@${config.networking.domain}";
acceptTerms = true;
};
}
The module will automatically setup a redis instance and a PostgreSQL database. Your NetBox instance is now available at: https://netbox.domain.tld
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/