2020-05-06 10:11:46 +00:00
|
|
|
# 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;
|
2020-05-06 10:11:46 +00:00
|
|
|
server_name {{ site.url }} www.{{ site.url }};
|
2020-04-01 07:41:12 +00:00
|
|
|
|
|
|
|
# Let's Encrypt
|
|
|
|
include snippets/letsencrypt.conf;
|
|
|
|
|
|
|
|
location / {
|
2020-05-06 10:11:46 +00:00
|
|
|
{% if site.redirect_to_www %}
|
|
|
|
return 301 https://www.{{ site.url }}$request_uri;
|
2020-04-27 07:45:07 +00:00
|
|
|
{% else %}
|
2020-05-06 10:11:46 +00:00
|
|
|
return 301 https://{{ site.url }}$request_uri;
|
2020-04-27 07:45:07 +00:00
|
|
|
{% endif %}
|
2020-04-01 07:41:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
server {
|
|
|
|
listen 443 ssl;
|
|
|
|
listen [::]:443 ssl;
|
2020-05-06 10:11:46 +00:00
|
|
|
server_name {{ site.url }} www.{{ site.url }};
|
2020-04-01 07:41:12 +00:00
|
|
|
|
2020-05-06 10:11:46 +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;
|
|
|
|
|
2020-05-06 10:11:46 +00:00
|
|
|
{% if site.redirect_to_www %}
|
2020-04-27 07:45:07 +00:00
|
|
|
# Redirect non-www to www
|
2020-05-06 10:11:46 +00:00
|
|
|
if ($host = {{ site.url }}) {
|
|
|
|
rewrite ^ https://www.{{ site.url }}$request_uri permanent;
|
2020-04-27 07:45:07 +00:00
|
|
|
}
|
|
|
|
{% else %}
|
|
|
|
# Redirect www to non-www
|
2020-05-06 10:11:46 +00:00
|
|
|
if ($host = www.{{ site.url }}) {
|
|
|
|
rewrite ^ https://{{ site.url }}$request_uri permanent;
|
2020-04-27 07:45:07 +00:00
|
|
|
}
|
|
|
|
{% 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;
|
2020-05-06 10:11:46 +00:00
|
|
|
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;
|
|
|
|
|
2020-05-06 10:11:46 +00:00
|
|
|
proxy_pass http://{{ site.subnet_nginx_ip }}:80;
|
2020-04-01 07:41:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|