Files
@ 71bc6c4991f8
Branch filter:
Location: majic-ansible-roles/roles/php_website/templates/nginx_site.j2 - annotation
71bc6c4991f8
2.4 KiB
text/plain
MAR-132: Fix virtual environment set-up in wsgi_website role:
- Install more up-to-date version of pip. This fixes some issues
related to pip freeze detecting argparse and wsgiref in virtualenv
as separate packages.
- Remove the pkg-resources package from virtualenv. Workaround for
Debian-specific behaviour. More details at:
- https://github.com/pypa/pip/issues/4022
- https://bugs.launchpad.net/ubuntu/+source/python-pip/+bug/1635463
- https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=871790
- Deploy Gunicorn requirements file without switching to website admin
user (otherwise Ansible fails to template the file due to
permissions restrictions).
- Updated test for checking packages installed in the virtualenv.
- Install more up-to-date version of pip. This fixes some issues
related to pip freeze detecting argparse and wsgiref in virtualenv
as separate packages.
- Remove the pkg-resources package from virtualenv. Workaround for
Debian-specific behaviour. More details at:
- https://github.com/pypa/pip/issues/4022
- https://bugs.launchpad.net/ubuntu/+source/python-pip/+bug/1635463
- https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=871790
- Deploy Gunicorn requirements file without switching to website admin
user (otherwise Ansible fails to template the file due to
permissions restrictions).
- Updated test for checking packages installed in the virtualenv.
dfb91e411e40 dfb91e411e40 dfb91e411e40 dfb91e411e40 dfb91e411e40 dfb91e411e40 dfb91e411e40 dfb91e411e40 dfb91e411e40 dfb91e411e40 dfb91e411e40 7727c37bce67 40473a82c752 7727c37bce67 40473a82c752 7727c37bce67 dfb91e411e40 7727c37bce67 d26fe0368a4b d26fe0368a4b d26fe0368a4b dfb91e411e40 d26fe0368a4b d26fe0368a4b d26fe0368a4b 18cd76ec050d 18cd76ec050d d26fe0368a4b 3dd7f39302f8 3352797ee517 3352797ee517 3352797ee517 3352797ee517 3352797ee517 1b05bae8e440 1b05bae8e440 1b05bae8e440 1b05bae8e440 1b05bae8e440 7f8ef577fa2c 40473a82c752 7727c37bce67 7727c37bce67 7f8ef577fa2c 7f8ef577fa2c 7727c37bce67 40473a82c752 7727c37bce67 40473a82c752 7727c37bce67 7727c37bce67 7727c37bce67 7f8ef577fa2c 40473a82c752 40473a82c752 40473a82c752 40473a82c752 40473a82c752 ff510f233909 40473a82c752 7727c37bce67 40473a82c752 222008c85003 97be416e882e 40473a82c752 40473a82c752 40473a82c752 40473a82c752 40473a82c752 7f8ef577fa2c 7f8ef577fa2c 7f8ef577fa2c 7727c37bce67 7f8ef577fa2c 7727c37bce67 4ca98a158269 4ca98a158269 4ca98a158269 4ca98a158269 4f7054d023b6 4ca98a158269 4ca98a158269 7727c37bce67 7727c37bce67 7727c37bce67 | {% if enforce_https -%}
server {
# HTTP (plaintext) configuration.
listen 80;
server_name {{ fqdn }};
# Redirect plaintext connections to HTTPS
return 301 https://$host$request_uri;
}
{% endif -%}
server {
# Base settings.
root {{ home }}/htdocs/;
index {{ index }};
server_name {{ fqdn }};
{% if not enforce_https %}
# HTTP (plaintext) configuration.
listen 80;
{% endif %}
# HTTPS (TLS) configuration.
listen 443 ssl;
listen [::]:443 ssl;
ssl_certificate_key /etc/ssl/private/{{ fqdn }}_https.key;
ssl_certificate /etc/ssl/certs/{{ fqdn }}_https.pem;
{% if enforce_https -%}
# Set-up HSTS header for preventing downgrades for users that visited the
# site via HTTPS at least once.
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains";
{% endif -%}
{% for config in additional_nginx_config -%}
# {{ config.comment }}
{{ config.value }}
{% endfor -%}
{% if rewrites -%}
# Generic URL rewrites.
{% for rewrite in rewrites -%}
rewrite {{ rewrite }};
{% endfor -%}
{% endif %}
{% if deny_files_regex -%}
# Deny access to user-specified files.
{% for regex in deny_files_regex -%}
location ~ {{ regex }} {
deny all;
}
{% endfor -%}
{% endif %}
# Interpret PHP files via FastCGI.
location ~ {{ php_file_regex }} {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/{{ php_fpm_service_name }}/{{ fqdn }}.sock;
}
# Serve the files.
location ~ /(.+) {
try_files $uri $uri/{% if php_rewrite_urls %} @php_rewrite{% else %} =404{% endif %};
}
{% if php_rewrite_urls -%}
# Apply URL rewrites.
location @php_rewrite {
{% for rewrite in php_rewrite_urls %}
rewrite {{ rewrite }};
{% endfor -%}
}
{% endif -%}
{% if environment_indicator -%}
# Show environment indicator on HTML pages.
sub_filter_types text/html;
sub_filter_once on;
sub_filter "</body>" "<div id='website-environment' style='background-color: {{ environment_indicator.background_colour }}; width: 100%; text-align: center; position: fixed; bottom: 5px; color: {{ environment_indicator.text_colour }}; font-weight: bold; z-index: 999999;'>{{ environment_indicator.text }}</div></body>";
{% endif -%}
access_log /var/log/nginx/{{ fqdn }}-access.log;
error_log /var/log/nginx/{{ fqdn }}-error.log;
}
|