Backup and nginx config

This commit is contained in:
Oleg Lavrovsky 2019-10-17 17:05:01 +02:00
parent 2d4cc65acd
commit ead009f381
2 changed files with 28 additions and 18 deletions

View File

@ -69,13 +69,18 @@ django-shell:
logs:
docker-compose logs -f --tail=500
backup:
backup-data:
docker-compose exec web ./manage.py dumpdata --natural-foreign -e auth.permission -e contenttypes -e wagtailcore.GroupCollectionPermission -e wagtailimages.rendition -e sessions -e feedler.feedlysettings > ~/publichealth.home.json
zip ~/publichealth.home.json.`date +"%d%m%Y-%H%M"`.zip ~/publichealth.home.json
rm ~/publichealth.home.json
backup-images:
echo "Backing up images ..."
sudo chown -R ansible media
zip -ruq ~/media.zip media
backup: backup-data backup-images
django-loaddata:
gunzip ~/publichealth.home.json.gz
docker-compose exec web ./manage.py loaddata ~/publichealth.home.json

View File

@ -6,21 +6,14 @@ upstream wagtail-site {
server localhost:5000;
}
server {
listen 80 default_server;
server_name _;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://wagtail-site;
}
listen 80 default_server;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl default_server;
server_name _;
listen 443 ssl default_server;
ssl on;
ssl_certificate /etc/certs/public-health.ch/cloudflare.pem;
ssl_certificate_key /etc/certs/public-health.ch/cloudflare.key;
@ -39,7 +32,7 @@ server {
access_log off; expires 36000;
alias {{ release_dir }}/static/;
add_header Cache-Control "public";
add_header Access-Control-Allow-Origin https://{{ domain }};
add_header Access-Control-Allow-Origin *; #https://{{ domain }};
}
# Set a longer expiry for CACHE/, because the filenames are unique.
@ -54,18 +47,30 @@ server {
alias {{ release_dir }}/static/images/favicon.ico;
}
# Only serve /media/images by default, not e.g. original_images/.
location /media/images {
alias {{ release_dir }}/media/images;
access_log off; expires max;
# Directly serve media with max caching
location /media {
root {{ release_dir }};
autoindex off;
access_log off;
expires max;
add_header Cache-Control "public";
}
# Only serve media by default, not e.g. original_images/.
#location ~* ^/media {
# alias {{ release_dir }}/media;
#}
# Disable English home page (for now)
if ($host = 'public-health.ch') {
if ($host !~* 'sphc.ch') {
rewrite ^/en/$ $scheme://$host/de/;
}
# Redirect French home page as appropriate
if ($host = 'manifestesante.ch') {
rewrite ^/$ $scheme://$host/fr/;
}
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;