#{{ ansible_managed }} # Main site configuration for public-health.ch 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; } } server { listen 443 ssl default_server; server_name _; ssl on; ssl_certificate /etc/certs/public-health.ch/cloudflare.pem; ssl_certificate_key /etc/certs/public-health.ch/cloudflare.key; client_max_body_size 16M; gzip on; gzip_types text/plain text/css application/x-javascript image/svg+xml; gzip_comp_level 1; gzip_disable msie6; gzip_http_version 1.0; gzip_proxied any; gzip_vary on; location /static/ { access_log off; expires 36000; alias {{ release_dir }}/static/; add_header Cache-Control "public"; add_header Access-Control-Allow-Origin https://{{ domain }}; } # Set a longer expiry for CACHE/, because the filenames are unique. location /static/CACHE/ { access_log off; expires 864000; alias {{ release_dir }}/static/CACHE/; } # Serve favorites icon from the root location /favicon.ico { access_log off; expires max; 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; add_header Cache-Control "public"; } # Disable English home page (for now) if ($host = 'public-health.ch') { rewrite ^/en/$ $scheme://$host/de/; } 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; } }