Add SCRIPT_NAME to the production-like server

This commit is contained in:
Martin Pépin 2017-08-13 14:36:45 +01:00
parent 4c08962e09
commit 2a519bfedf
4 changed files with 38 additions and 44 deletions

View file

@ -77,9 +77,9 @@ comme en production : on utilise
derrière un reverse-proxy nginx.
Ce serveur se lance tout seul et est accessible en dehors de la VM à l'url
`localhost:8080`. Toutefois il ne se recharge pas tout seul lorsque le code
change, il faut relancer le worker avec `sudo systemctl restart worker.service`
pour visualiser la dernière version du code.
`localhost:8080/gestion/`. Toutefois il ne se recharge pas tout seul lorsque le
code change, il faut relancer le worker avec `sudo systemctl restart
worker.service` pour visualiser la dernière version du code.
### Installation manuelle

View file

@ -3,10 +3,8 @@ Django development settings for the cof project.
The settings that are not listed here are imported from .common
"""
import os
from .common import * # NOQA
from .common import BASE_DIR, INSTALLED_APPS, MIDDLEWARE_CLASSES
from .common import INSTALLED_APPS, MIDDLEWARE_CLASSES
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'

View file

@ -24,8 +24,9 @@ REDIS_PASSWD="dummy"
redis-cli CONFIG SET requirepass $REDIS_PASSWD
redis-cli -a $REDIS_PASSWD CONFIG REWRITE
# Contenu static
mkdir -p /srv/gestiocof/{media,static}
# Contenu statique
mkdir -p /srv/gestiocof/media
mkdir -p /srv/gestiocof/static
chown -R ubuntu:www-data /srv/gestiocof
# Nginx

View file

@ -7,45 +7,15 @@ server {
listen 80;
server_name localhost;
root /srv/gestiocof/;
# All the trafic is routed to Daphne
location / {
# A copy-paste of what we have in production
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-SSL-Client-Serial $ssl_client_serial;
proxy_set_header X-SSL-Client-Verify $ssl_client_verify;
proxy_set_header X-SSL-Client-S-DN $ssl_client_s_dn;
# Reverse-proxy
proxy_pass http://gestiocof;
}
# Upgrading the connection when handling websockets
location /ws/ {
# A copy-paste of what we have in production
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-SSL-Client-Serial $ssl_client_serial;
proxy_set_header X-SSL-Client-Verify $ssl_client_verify;
proxy_set_header X-SSL-Client-S-DN $ssl_client_s_dn;
# See http://nginx.org/en/docs/http/websocket.html
proxy_buffering off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_pass http://gestiocof;
}
# / /gestion/
# /gestion /gestion/
rewrite ^/$ /gestion/;
rewrite ^/gestion$ /gestion/;
# Static files
location /static/ {
root /srv/gestiocof/;
access_log off;
add_header Cache-Control "public";
expires 7d;
@ -53,9 +23,34 @@ server {
# Uploaded media
location /media/ {
root /srv/gestiocof/;
access_log off;
add_header Cache-Control "public";
expires 7d;
}
location /gestion/ {
# A copy-paste of what we have in production
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-SSL-Client-Serial $ssl_client_serial;
proxy_set_header X-SSL-Client-Verify $ssl_client_verify;
proxy_set_header X-SSL-Client-S-DN $ssl_client_s_dn;
proxy_set_header Daphne-Root-Path /gestion;
location /gestion/ws/ {
# See http://nginx.org/en/docs/http/websocket.html
proxy_buffering off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_pass http://gestiocof/ws/;
}
location /gestion/ {
proxy_pass http://gestiocof;
}
}
}