Vous êtes sur la page 1sur 2

Mise en place de Nginx

Instruction Action
Créer dans l’arborescence du projet un dossier nginx contenant deux
fichiers :
- Dockerfile
- Default.conf
upstream django {
server web:6998;

server {
listen 80;
Dans le fichier default.conf, rajouter le code suivant :
location /{
proxy_pass http://django;
}

location /web/ {
alias /web/;
}
}
FROM nginx:1.19.0-alpine
Dans le fichier Dockerfile, rajouter le code suivant :
COPY ./default.conf /etc/nginx/conf.d/default.conf
nginx:
build: ./nginx
volumes:
- ./web:web
Dans le fichier docker-compose.yml, rajouter le code suivant : ports:
- "8${MACHINE_ID}:80"
restart: always
depends_on:
- web
Ajouter au service web le code suivant :
env_file:

- .env

Modifier le services web

ports:
- "6${MACHINE_ID}:6${MACHINE_ID}"
environment:
- APP_PORT=6${MACHINE_ID}
Dans le fichier docker-compose.yml, modifier les lignes suivantes : - DEBUG=${DEBUG}

Modifier le service com


ports:
- "6${MACHINE_ID}:6${MACHINE_ID}"
environment:
- APP_PORT=6${MACHINE_ID}

A la fin du fichier, rajouter web au volumes


volumes:
arp_web_machine:
web:

#Avoid CSRF attack by defining trust IP adresse: If not,CSRF


ERROR TOKEN
CSRF_TRUSTED_ORIGINS = {
Dans le fichier settings.py de l’application web, rajouter le code 'http://127.0.0.1:8998',
suivant :
'http://192.168.36.51:8998'
}
SECURE_CROSS_ORIGIN_OPENER_POLICY = None
DEBUG = False #Set DEBUG to False for Production (gunicorn) or
Dans le fichier .env, rajouter le code suivant : true for Development (runserver)

Vous aimerez peut-être aussi