---
# System prepended metadata

title: Documentation Projet individuel Ydays Pole Réseau

---

# Documentation Projet individuel Ydays Pole Réseau
## Demande du projet :

Mise en place d’un Netbox avec une BDD PostgreSQL et d’un reverse proxy.

## Schéma du projet :

![](https://i.imgur.com/WCwZkKr.png)

## Configuration :

### Installation de netbox:

Installation de postgresql et des dependance de netbox
```
sudo apt-get update
sudo apt-get install -y git gcc nginx redis supervisor python3 python3-dev python3-pip python3-setuptools build-essential libxml2-dev libxslt1-dev libffi-dev graphviz libpq-dev libssl-dev zlib1g-dev

systemctl start postgresql
systemctl enable postgresql

sudo -u postgres psql psql

CREATE DATABASE netbox;
CREATE USER netbox WITH PASSWORD ‘StrongPassword’;
GRANT ALL PRIVILEGES ON DATABASE netbox TO netbox;
```

Installation de netbox:
```
cd /opt/
sudo git clone -b master https://github.com/digitalocean/netbox.git

cd netbox/netbox/netbox/
sudo cp configuration.example.py configuration.py
```

On edit le fichier pour emplir le ALLOWED_HOSTS et le PASSWORD:
```bash=
# Example: ALLOWED_HOSTS = ['netbox.example.com', 'netbox.internal.local']
ALLOWED_HOSTS = ['localhost']

# PostgreSQL database configuration.
DATABASE = {
    'NAME': 'netbox',                           # Database name
    'USER': 'netbox',                           # PostgreSQL username
    'PASSWORD': 'StrongPassword',               # PostgreSQL password
    'HOST': 'localhost',                        # Database server
    'PORT': '',                                 # Database port (leave blank for default)
}
```

Copier la clé Django
```
cd /opt/netbox/netbox
sudo ./generate_secret_key.py
sudo vim  /opt/netbox/netbox/netbox/configuration.py
```

Install des dependances

```
sudo pip3 install -r /opt/netbox/requirements.txt
```
On migre la BDD et on crée le supersuser
```
cd /opt/netbox/netbox/
sudo python3 manage.py migrate

sudo python3 manage.py createsuperuser

cd /opt/netbox/netbox
sudo python3 manage.py collectstatic
```

Install de Gunicorn:

```
sudo cp -v /opt/netbox/contrib/*.service /etc/systemd/system/
sudo systemctl daemon-reload

sudo systemctl start netbox netbox-rq
sudo systemctl enable netbox netbox-rq

systemctl status netbox.service

```

Installation serveur http

```
sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 \
-keyout /etc/ssl/private/netbox.key \
-out /etc/ssl/certs/netbox.crt
sudo apt install -y nginx

sudo cp /opt/netbox/contrib/nginx.conf /etc/nginx/sites-available/netbox

sudo rm /etc/nginx/sites-enabled/default
sudo ln -s /etc/nginx/sites-available/netbox /etc/nginx/sites-enabled/netbox

sudo systemctl restart nginx
```

Et voila on accede a la web ui:

![](https://i.imgur.com/SUEQRoz.png)

### installation de reverse-proxy sur Nginx

```
sudo touch /etc/nginx/sites-available/rproxy-rdr-it-io
sudo vim /etc/nginx/sites-available/rproxy-rdr-it-io
```

```bash=
server{
    # Port listen
    listen 80;

    # DNS Record for catch request
    server_name rproxy.rdr-it.io;

    # Open block for process forward request
    location /{
        # Server where traffic is transferred
        proxy_pass http://srv-web-iis;
        # Include file proxy_params with general param
        include proxy_params;
    }
}
```

```
sudo ln -s /etc/nginx/sites-available/rproxy-rdr-it-io /etc/nginx/sites-enabled
sudo nginx -t
sudo systemctl reload nginx
```