Professional Documents
Culture Documents
04
apt-get update -y
apt-get upgrade -y
apt-get install wget ca-certificates nginx supervisor git gcc python3 python3-dev
python3-pip python3-setuptools build-essential libxml2-dev libxslt1-dev libffi-dev
graphviz libpq-dev libssl-dev zlib1g-dev unzip -y
PostgreSQL
vi /etc/apt/sources.list.d/postgres.list
a�adir:
deb http://apt.postgresql.org/pub/repos/apt/ xanial-pgdg main
apt-get update -y
apt-get install postgresql postgresql-contrib -y
Creamos la BD
su - postgres
psql
Instalamos NetBox
cd /opt
git clone -b master https://github.com/digitalocean/netbox.git
cd /opt/netbox/netbox
./generate_secret_key.py
_^-w#eTZ+o8MtSkyPn(=xaORCUDdIQ@920buKGHAhNr5g%4*mE
cd netbox
mv configuration.example.py configuration.py
vi configuration.py
-En allowed hosts ponemos un nombre que hayamos puesto antes en el /etc/hosts para
que resuelva
ALLOWED_HOSTS = ['netboxnet.test.local']
# This key is used for secure generation of random numbers and strings. It must
never be exposed outside of this file.
# For optimal security, SECRET_KEY should be at least 50 characters in length and
contain a mix of letters, numbers, and
# symbols. NetBox will not run without this defined. For more information, see
# https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-SECRET_KEY
SECRET_KEY = '_^-w#eTZ+o8MtSkyPn(=xaORCUDdIQ@920buKGHAhNr5g%4*mE'
Instalamos dependencias:
Migramos la BD:
cd /opt/netbox/netbox/
python3 manage.py migrate
Y editamos su config:
vi /opt/netbox/gunicorn_config.py
Y a�adimos:
command = '/usr/local/bin/gunicorn'
pythonpath = '/opt/netbox/netbox'
bind = 'ip_servidor:8001'
workers = 3
user = 'www-data'
vi /etc/supervisor/conf.d/netbox.conf
A�adimos:
[program:netbox]
command = gunicorn -c /opt/netbox/gunicorn_config.py netbox.wsgi
directory = /opt/netbox/netbox/
user = www-data
vi /etc/nginx/sites-available/netbox
A�adimos:
server {
listen 80;
server_name nombre_con_domino;
client_max_body_size 25m;
location /static/ {
alias /opt/netbox/netbox/static/;
}
location / {
proxy_pass http://ip_servidor:8001;
proxy_set_header X-Forwarded-Host $server_name;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
add_header P3P 'CP="ALL DSP COR PSAa PSDa OUR NOR ONL UNI COM NAV"';
}
}
ln -s /etc/nginx/sites-available/netbox.conf /etc/nginx/sites-enabled/