automation/deployer/roles/build/templates/wordpress/nginx.host.j2

57 lines
1.3 KiB
Text
Raw Normal View History

# Generated by ansible for site {{ site.url }}
# At {{ site.subnet_site_ip }} on {{ site.subnet_cidr_address }}
2020-04-01 07:41:12 +00:00
server {
listen 80;
listen [::]:80;
server_name {{ site.url }} www.{{ site.url }};
2020-04-01 07:41:12 +00:00
# Let's Encrypt
include snippets/letsencrypt.conf;
location / {
{% if site.redirect_to_www %}
return 301 https://www.{{ site.url }}$request_uri;
{% else %}
return 301 https://{{ site.url }}$request_uri;
{% endif %}
2020-04-01 07:41:12 +00:00
}
}
server {
listen 443 ssl;
listen [::]:443 ssl;
server_name {{ site.url }} www.{{ site.url }};
2020-04-01 07:41:12 +00:00
access_log /var/log/nginx/{{ site.slug }}-access.log;
2020-04-01 07:41:12 +00:00
error_log /var/log/nginx/error.log;
{% if site.redirect_to_www %}
# Redirect non-www to www
if ($host = {{ site.url }}) {
rewrite ^ https://www.{{ site.url }}$request_uri permanent;
}
{% else %}
# Redirect www to non-www
if ($host = www.{{ site.url }}) {
rewrite ^ https://{{ site.url }}$request_uri permanent;
}
{% endif %}
2020-04-09 15:29:12 +00:00
2020-04-01 07:41:12 +00:00
# Let's Encrypt
include snippets/letsencrypt.conf;
include snippets/ssl-params.conf;
ssl_certificate /etc/letsencrypt/live/{{ site.url }}/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/{{ site.url }}/privkey.pem;
2020-04-01 07:41:12 +00:00
include snippets/header-params_server.conf;
location / {
include snippets/header-params_location.conf;
proxy_pass http://{{ site.subnet_nginx_ip }}:80;
2020-04-01 07:41:12 +00:00
}
}