server {
listen {{ isHTTPS() ? '443 ssl' : '80' }}{{ isHTTP2() ? ' http2' : '' }};
listen [::]:{{ isHTTPS() ? '443 ssl' : '80' }}{{ isHTTP2() ? ' http2' : '' }};
server_name {{ isWWW() ? 'www.' : '' }}{{ domain() }};
set $base /var/www/{{ domain() }};
root $base{{ data.document_root }};
root /var/www/{{ domain() }}{{ data.document_root }};
# SSL certificate
ssl_certificate {{ sslCertificate() }};
ssl_certificate_key {{ sslCertificateKey() }};
ssl_trusted_certificate /etc/letsencrypt/live/{{ domain() }}/fullchain.pem;
# SSL config
include _ssl.conf;
# index
index {{ isIndexHtml() ? 'index.html ' : '' }}index.php;
# $uri{{ isIndexHtml() ? ', index.html' : '' }}{{ isIndexPhp() ? ', index.php' : '' }}
location / {
try_files $uri $uri/ {{ isIndexHtml() ? '/index.html' : '' }}{{ isIndexHtml() && isIndexPhp() ? ' ' : '' }}{{ isIndexPhp() ? '/index.php?$query_string' : '' }};
}
include _letsencrypt.conf;
include _general.conf;
include _wordpress.conf;
include _php.conf;
}
# CDN
server {
listen {{ isHTTPS() ? '443 ssl' : '80' }}{{ isHTTP2() ? ' http2' : '' }};
listen [::]:{{ isHTTPS() ? '443 ssl' : '80' }}{{ isHTTP2() ? ' http2' : '' }};
server_name cdn.{{ domain() }};
root /var/www/{{ domain() }}{{ data.document_root }};
access_log off;
# SSL certificate
ssl_certificate {{ sslCertificate() }};
ssl_certificate_key {{ sslCertificateKey() }};
ssl_trusted_certificate /etc/letsencrypt/live/{{ domain() }}/fullchain.pem;
# SSL config
include _ssl.conf;
include _letsencrypt.conf;
# disable access_log
access_log off;
# gzip
gzip on;
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_types {{ gzipTypes }};
# allow safe files
location ~* \.(?:{{ extensions.assets }}|{{ extensions.fonts }}|{{ extensions.svg }}|{{ extensions.images }}|{{ extensions.audio }}|{{ extensions.video }}|{{ extensions.docs }})$ {
add_header Access-Control-Allow-Origin "*";
add_header Cache-Control "public";
expires 30d;
}
# deny everything else
location / {
deny all;
}
}
# {{ isWWW() ? 'non-www, ' : '' }}subdomains redirect
server {
listen {{ isHTTPS() ? '443 ssl' : '80' }}{{ isHTTP2() ? ' http2' : '' }};
listen [::]:{{ isHTTPS() ? '443 ssl' : '80' }}{{ isHTTP2() ? ' http2' : '' }};
server_name {{ isWWW() ? domain() + ' ' : '' }}*.{{ domain() }};
# SSL certificate
ssl_certificate /etc/letsencrypt/live/{{ domain() }}/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/{{ domain() }}/privkey.pem;
ssl_trusted_certificate /etc/letsencrypt/live/{{ domain() }}/fullchain.pem;
# SSL config
include _ssl.conf;
return 301 https://{{ isWWW() ? 'www.' : '' }}{{ domain() }}$request_uri;
}
# HTTP redirect
server {
listen 80;
listen [::]:80;
server_name {{ domain() }} *.{{ domain() }};
return 301 https://{{ isWWW() ? 'www.' : '' }}{{ domain() }}$request_uri;
}