NetBox: Difference between revisions
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 |
- added encryption configuration - added Troubleshooting information - fixed some minor bugs in the basic configuration description |
||
| Line 2: | Line 2: | ||
== Setup == | == 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 the configuration (i.e. in /nix/store) and it must be at least 50 characters long: | |||
You should | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
| Line 13: | Line 13: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
===== Basic Configuration | === Configuration === | ||
The module will automatically | |||
==== Basic Configuration ==== | |||
The module will automatically set up a Redis instance and a PostgreSQL database.<syntaxhighlight lang="nix"> | |||
{ config, ... }: { | { config, ... }: { | ||
| Line 26: | Line 28: | ||
services.nginx = { | services.nginx = { | ||
enable = true; | enable = true; | ||
user = "netbox"; # otherwise nginx cant access netbox files | |||
recommendedProxySettings = true; # otherwise you will get CSRF error while login | |||
virtualHosts.<name> = { | virtualHosts.<name> = { | ||
locations = { | locations = { | ||
| Line 39: | Line 43: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
==== With Transport encryption ==== | |||
<syntaxhighlight lang="nix"> | |||
{ config, ... }: { | |||
networking.firewall.allowedTCPPorts = [ 80 ]; | |||
services.netbox = { | |||
enable = true; | |||
secretKeyFile = "/var/lib/netbox/secret-key-file"; | |||
}; | |||
services.nginx = { | |||
enable = true; | |||
forceSSL = true; | |||
user = "netbox"; # otherwise nginx cant access netbox files | |||
recommendedProxySettings = true; # otherwise you will get CSRF error while login | |||
recommendedTlsSettings = true; | |||
enableACME = 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/"; }; | |||
}; | |||
}; | |||
}; | |||
security.acme = { | |||
[ ... ] | |||
acceptTerms = true; | |||
}; | |||
} | |||
</syntaxhighlight>For more acme settings and further instruction, please look here [[Acme]]. | |||
For more nginx settings and further instruction, please look here [[Nginx|Nginx.]] | |||
=== Setup Superuser === | === Setup Superuser === | ||
There will be no user after the installation, so you need to | There will be no user after the installation, so you need to register one manually. | ||
To do this, run: | To do this, run: | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
| Line 55: | Line 98: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
You can now log in with the given credentials. | |||
=== Troubleshooting === | |||
==== CSRF aborted message at login ==== | |||
If you still get an CSRF aborted message while trying to log in after doing everything above, please try to use another browser. | |||
It could be these problem https://stackoverflow.com/questions/11516635/django-does-not-send-csrf-token-again-after-browser-cookies-has-been-cleared but I'm not sure. | |||
== Documentation == | == Documentation == | ||