server { listen 443 ssl; listen [::]:443 ssl; server_name {{ site }}; ssl_certificate {{ tls_certs }}/{{ site }}-fullchain.crt; ssl_certificate_key {{ tls_private }}/{{ site }}.key; {% if redirect is defined %} return 301 {{ redirect }}; {% elif proxy is defined %} location / { proxy_pass {{ proxy }}; proxy_ssl_certificate {{ tls_certs }}/{{ inventory_hostname }}.crt; proxy_ssl_certificate_key {{ tls_private }}/{{ inventory_hostname }}.key; } {% else %} root /srv/web/{{ site }}; {% endif %} include /etc/nginx/conf.d/{{ site }}/*.conf; } server { ssl off; listen 80; listen [::]:80; server_name {{ site }}; location /.well-known/acme-challenge/ { proxy_pass https://noc02.home.foo.sh/.well-known/acme-challenge/; proxy_ssl_certificate {{ tls_certs }}/{{ inventory_hostname }}.crt; proxy_ssl_certificate_key {{ tls_private }}/{{ inventory_hostname }}.key; } location / { {% if redirect is defined %} return 301 {{ redirect }}; {% else %} return 301 https://$host$request_uri; {% endif %} } }