Skip to content

Commit 37840b5

Browse files
committed
updated prod conf files
1 parent 9e31264 commit 37840b5

File tree

7 files changed

+98
-59
lines changed

7 files changed

+98
-59
lines changed

iTeam/settings.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# @Author: Adrien Chardon
44
# @Date: 2014-09-02 12:01:06
55
# @Last Modified by: Adrien Chardon
6-
# @Last Modified time: 2014-11-02 17:17:31
6+
# @Last Modified time: 2014-11-02 21:25:55
77

88
# This file is part of iTeam.org.
99
# Copyright (C) 2014 Adrien Chardon (Nodraak).
@@ -156,6 +156,7 @@
156156
)
157157

158158
MIDDLEWARE_CLASSES = (
159+
'django.middleware.common.BrokenLinkEmailsMiddleware',
159160
'django.contrib.sessions.middleware.SessionMiddleware',
160161
'django.middleware.common.CommonMiddleware',
161162
'django.middleware.csrf.CsrfViewMiddleware',

prod/deploy.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
* Nginx
1717
* apt-get install
1818
* Conf file :
19-
* `cp prod/nginx.conf /etc/nginx/sites-available/iteam` + maintenance
19+
* `cp prod/nginx-global.conf /etc/nginx/sites-available/iteam-global` + `cp prod/nginx-prod.conf /etc/nginx/sites-available/iteam-prod` + `cp prod/nginx-maintenance.conf /etc/nginx/sites-available/iteam-maintenance`
2020
* `vim /etc/nginx/sites-available/iteam` -> static/ + media/ path
2121
* cp favicon robots.txt + check conf file
22-
* `ln -s /etc/nginx/sites-available/iteam /etc/nginx/sites-enabled/iteam`
22+
* `ln -s /etc/nginx/sites-available/iteam-prod /etc/nginx/sites-enabled/iteam`
2323
* check nginx conf : `nginx -t`
2424
* Gunicorn
2525
* `pip install gunicorn`
@@ -108,7 +108,7 @@ A lire :
108108
* django cache https://docs.djangoproject.com/en/dev/topics/cache/
109109
* nginx + static + gzip : http://sametmax.com/servir-des-fichiers-statiques-avec-nginx/
110110
* migrate http://www.djangopro.com/2011/01/django-database-migration-tool-south-explained/
111-
111+
* nginx : root vs alias : http://nginx.org/en/docs/http/ngx_http_core_module.html#alias + http://nginx.org/en/docs/http/ngx_http_core_module.html#root
112112

113113

114114
# Django settings : `settings_prod.py`

prod/deploy.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ cd /opt/iteam-env/iteam-site/
1616

1717
# Maintenance mode
1818
sudo rm /etc/nginx/sites-enabled/iteam
19-
sudo ln -s /etc/nginx/sites-available/iteam-maintenance /etc/nginx/sites-enabled/iteam-maintenance
19+
sudo ln -s /etc/nginx/sites-available/iteam-maintenance /etc/nginx/sites-enabled/iteam
2020
sudo service nginx reload
2121

2222
# save database if something fail
@@ -48,8 +48,8 @@ deactivate
4848
sudo supervisorctl restart iteam
4949

5050
# Exit maintenance mode
51-
sudo rm /etc/nginx/sites-enabled/iteam-maintenance
52-
sudo ln -s /etc/nginx/sites-available/iteam /etc/nginx/sites-enabled/iteam
51+
sudo rm /etc/nginx/sites-enabled/iteam
52+
sudo ln -s /etc/nginx/sites-available/iteam-prod /etc/nginx/sites-enabled/iteam
5353
sudo service nginx reload
5454

5555
# Display current branch and commit

prod/gunicorn_start.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ exec ../bin/gunicorn iTeam.wsgi:application \
1818
--name=iTeam \
1919
--user=$USER \
2020
--group=$GROUP \
21-
--log-level=debug \
21+
--log-level=info \
2222
--log-file=$LOGFILE 2>>$ERRFILE

prod/nginx-maintenance.conf

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,64 @@
1+
#
2+
# si ca chie, ping Speedking @zestedesavoir.com
3+
#
4+
15

26
# Redirect www.domain.tld to domain.tld
37
#server {
48
# listen 80;
5-
# server_name www.example.com;
9+
# server_name www.iteam.org;
610
#
7-
# return 301 http://example.com$request_uri;
11+
# return 301 http://iteam.org$request_uri;
812
#}
913

1014
server {
1115
listen 80;
1216
server_name beta.iteam.org;
1317

18+
# log
1419
access_log /opt/iteam-env/log/nginx-access.log;
1520
error_log /opt/iteam-env/log/nginx-error.log;
1621

1722

1823
# media and static files
19-
2024
location /static/ {
21-
alias /opt/iteam-env/static/;
25+
root /opt/iteam-env;
2226
expires 1d;
2327
add_header Pragma public;
2428
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
2529
}
26-
2730
location /media/ {
28-
alias /opt/iteam-env/media/;
31+
root /opt/iteam-env;
2932
expires 1d;
3033
add_header Pragma public;
3134
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
3235
}
3336

37+
# misc
3438
location /favicon.ico {
35-
root /opt/iteam-env/iteam-site/static/images/;
39+
root /opt/iteam-env/static/images;
3640
}
37-
3841
location /robots.txt {
39-
root /opt/iteam-env/iteam-site/static/;
42+
root /opt/iteam-env/static;
4043
}
4144

42-
# bind 503 to maintenance.html
43-
error_page 503 /maintenance.html;
44-
45-
# return 503 for all requests
46-
location / {
47-
return 503;
45+
# Error pages
46+
error_page 500 501 502 503 504 /500.html;
47+
location = /500.html {
48+
root /opt/iteam-env/iteam-site/templates;
4849
}
4950

50-
# serve maintenance.html
51+
# bind 503 to maintenance.html + location of maintenance.html
52+
error_page 503 /maintenance.html;
53+
5154
location /maintenance.html {
52-
root /opt/iteam-env/iteam-site/templates/;
55+
root /opt/iteam-env/iteam-site/templates;
5356
}
5457

58+
################################################################################
5559

56-
# Error pages
57-
58-
error_page 500 501 502 503 504 /500.html;
59-
location = /500.html {
60-
root /opt/iteam-env/iteam-site/templates/;
60+
# serve maintenance.html
61+
location / {
62+
return 503;
6163
}
6264
}
63-

prod/nginx.conf renamed to prod/nginx-prod.conf

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,36 +15,49 @@ server {
1515
listen 80;
1616
server_name beta.iteam.org;
1717

18+
# log
1819
access_log /opt/iteam-env/log/nginx-access.log;
1920
error_log /opt/iteam-env/log/nginx-error.log;
2021

2122

2223
# media and static files
23-
2424
location /static/ {
25-
alias /opt/iteam-env/static/;
25+
root /opt/iteam-env;
2626
expires 1d;
2727
add_header Pragma public;
2828
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
2929
}
30-
3130
location /media/ {
32-
alias /opt/iteam-env/media/;
31+
root /opt/iteam-env;
3332
expires 1d;
3433
add_header Pragma public;
3534
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
3635
}
3736

37+
# misc
3838
location /favicon.ico {
39-
root /opt/iteam-env/iteam-site/static/images/;
39+
root /opt/iteam-env/static/images;
4040
}
41-
4241
location /robots.txt {
43-
root /opt/iteam-env/iteam-site/static/;
42+
root /opt/iteam-env/static;
43+
}
44+
45+
# Error pages
46+
error_page 500 501 502 503 504 /500.html;
47+
location = /500.html {
48+
root /opt/iteam-env/iteam-site/templates;
4449
}
4550

46-
# default : redirect to gunicorn (which will redirect to django)
51+
# bind 503 to maintenance.html + location of maintenance.html
52+
error_page 503 /maintenance.html;
53+
54+
location /maintenance.html {
55+
root /opt/iteam-env/iteam-site/templates;
56+
}
4757

58+
################################################################################
59+
60+
# redirect to gunicorn (which will redirect to django)
4861
location / {
4962
client_max_body_size 100M;
5063
proxy_read_timeout 300s;
@@ -58,13 +71,4 @@ server {
5871

5972
proxy_pass http://localhost:8000/;
6073
}
61-
62-
63-
# Error pages
64-
65-
error_page 500 501 502 503 504 /500.html;
66-
location = /500.html {
67-
root /opt/iteam-env/iteam-site/templates/;
68-
}
6974
}
70-

prod/settings_prod.py

Lines changed: 44 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,28 @@
44
import os
55
SITE_ROOT = os.path.realpath(os.path.dirname(os.path.dirname(__file__)))
66

7+
################################
8+
# Basic and misc
9+
################################
710

811
DEBUG = False
912
TEMPLATE_DEBUG = False
1013
SERVE = False
1114

12-
1315
ALLOWED_HOSTS = ['localhost']
1416

1517
# Make this unique, and don't share it with anybody.
1618
# SECURITY WARNING: keep the secret key used in production secret!
1719
SECRET_KEY = 'z3rte+c4hikqi-csxbs2&j#+5%nwwbe=ki0j957a^i1%k-hs^^'
1820

21+
################################
22+
# Static and media
23+
################################
1924

20-
ADMINS = (('Adrien Chardon', 'johndoe@gmail.com'),)
21-
SERVER_EMAIL = 'contact_iteam@famillechardon.fr'
22-
EMAIL_HOST = 'mail.mailoo.org'
23-
EMAIL_HOST_USER = '**********'
24-
EMAIL_HOST_PASSWORD = '*********'
25-
EMAIL_PORT = 25
26-
27-
28-
STATIC_ROOT = os.path.join(SITE_ROOT, '..', 'static')
25+
STATIC_ROOT = '/opt/iteam-env/static'
2926
STATIC_URL = '/static/'
3027

31-
MEDIA_ROOT = os.path.join(SITE_ROOT, '..', 'media')
28+
MEDIA_ROOT = '/opt/iteam-env/media'
3229
MEDIA_URL = '/media/'
3330

3431
STATICFILES_DIRS = (
@@ -37,9 +34,45 @@
3734
('images', os.path.join(SITE_ROOT, 'assets', 'images')),
3835
)
3936

37+
################################
38+
# Database
39+
################################
40+
4041
DATABASES = {
4142
'default': {
4243
'ENGINE': 'django.db.backends.sqlite3',
4344
'NAME': os.path.join(SITE_ROOT, 'db.sqlite3'),
4445
}
4546
}
47+
48+
################################
49+
# Email and errors report
50+
################################
51+
52+
EMAIL_HOST = 'mail.mailoo.org'
53+
EMAIL_HOST_USER = '**********'
54+
EMAIL_HOST_PASSWORD = '*********'
55+
EMAIL_PORT = 25
56+
57+
# Email address that error messages come from.
58+
SERVER_EMAIL = 'siteweb@iteam.org'
59+
# Default email address to use for various automated correspondence from the site managers.
60+
DEFAULT_FROM_EMAIL = 'siteweb@iteam.org'
61+
62+
# Subject-line prefix for email messages send with django.core.mail.mail_admins or ...mail_managers.
63+
# Make sure to include the trailing space.
64+
EMAIL_SUBJECT_PREFIX = '[Django] '
65+
66+
# People who get code error notifications.
67+
ADMINS = (('John Doe', 'johndoe@gmail.com'),)
68+
# Not-necessarily-technical managers of the site. They get broken link notifications and other various emails.
69+
MANAGERS = ADMINS
70+
71+
# Whether to send broken-link emails. Deprecated, must be removed in 1.8.
72+
SEND_BROKEN_LINK_EMAILS = False
73+
74+
#IGNORABLE_404_URLS = (
75+
# re.compile(r'^/apple-touch-icon.*\.png$'),
76+
# re.compile(r'^/favicon.ico$'),
77+
# re.compile(r'^/robots.txt$'),
78+
# )

0 commit comments

Comments
 (0)