2020-06-01 08:52:52 +00:00
|
|
|
server {
|
2020-11-11 10:41:06 +00:00
|
|
|
% if domain_aliases:
|
|
|
|
server_name ${domain} ${' '.join(sorted(domain_aliases))};
|
|
|
|
% else:
|
2020-06-01 08:52:52 +00:00
|
|
|
server_name ${domain};
|
2020-11-11 10:41:06 +00:00
|
|
|
% endif
|
2020-10-31 09:41:33 +00:00
|
|
|
root ${webroot if webroot else '/var/www/{}/'.format(vhost)};
|
|
|
|
index ${' '.join(index)};
|
2020-06-01 08:52:52 +00:00
|
|
|
|
2021-04-25 07:20:16 +00:00
|
|
|
listen 80;
|
|
|
|
listen [::]:80;
|
|
|
|
|
2021-02-20 13:25:27 +00:00
|
|
|
% if ssl:
|
2021-04-25 07:20:16 +00:00
|
|
|
location / {
|
2024-02-13 12:57:53 +00:00
|
|
|
return 301 https://${domain}$request_uri;
|
2021-04-25 07:20:16 +00:00
|
|
|
}
|
|
|
|
|
2024-02-13 12:57:53 +00:00
|
|
|
% if ssl == 'letsencrypt':
|
2021-04-25 07:20:16 +00:00
|
|
|
location /.well-known/acme-challenge/ {
|
|
|
|
alias /var/lib/dehydrated/acme-challenges/;
|
|
|
|
}
|
2024-02-13 12:57:53 +00:00
|
|
|
% endif
|
2021-04-25 07:20:16 +00:00
|
|
|
}
|
|
|
|
|
2024-02-13 13:01:40 +00:00
|
|
|
% if domain_aliases and force_domain:
|
2021-04-25 07:20:16 +00:00
|
|
|
server {
|
2024-02-13 12:57:53 +00:00
|
|
|
server_name ${' '.join(sorted(domain_aliases))};
|
|
|
|
|
2021-04-25 07:20:16 +00:00
|
|
|
root ${webroot if webroot else '/var/www/{}/'.format(vhost)};
|
|
|
|
index ${' '.join(index)};
|
|
|
|
|
2024-04-24 21:04:06 +00:00
|
|
|
listen 443 ssl;
|
|
|
|
listen [::]:443 ssl;
|
|
|
|
http2 on;
|
2020-06-01 08:52:52 +00:00
|
|
|
|
2021-04-25 07:20:16 +00:00
|
|
|
% if ssl == 'letsencrypt':
|
2020-06-01 08:52:52 +00:00
|
|
|
ssl_certificate /var/lib/dehydrated/certs/${domain}/fullchain.pem;
|
|
|
|
ssl_certificate_key /var/lib/dehydrated/certs/${domain}/privkey.pem;
|
2021-04-25 07:20:16 +00:00
|
|
|
% else:
|
2021-04-25 07:09:23 +00:00
|
|
|
ssl_certificate /etc/nginx/ssl/${vhost}.crt;
|
|
|
|
ssl_certificate_key /etc/nginx/ssl/${vhost}.key;
|
2021-04-25 07:20:16 +00:00
|
|
|
% endif
|
2020-06-01 08:52:52 +00:00
|
|
|
ssl_dhparam /etc/ssl/certs/dhparam.pem;
|
2020-06-01 09:01:00 +00:00
|
|
|
ssl_protocols TLSv1.2 TLSv1.3;
|
|
|
|
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
|
2020-06-01 08:52:52 +00:00
|
|
|
ssl_prefer_server_ciphers on;
|
|
|
|
ssl_session_cache shared:SSL:10m;
|
2021-01-24 17:44:13 +00:00
|
|
|
ssl_session_tickets off;
|
2020-09-20 13:46:39 +00:00
|
|
|
|
2024-02-13 12:57:53 +00:00
|
|
|
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains";
|
|
|
|
|
|
|
|
% if ssl == 'letsencrypt':
|
|
|
|
location /.well-known/acme-challenge/ {
|
|
|
|
alias /var/lib/dehydrated/acme-challenges/;
|
|
|
|
}
|
|
|
|
% endif
|
|
|
|
|
|
|
|
location / {
|
|
|
|
return 301 https://${domain}$request_uri;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
% endif
|
|
|
|
server {
|
2024-02-13 13:01:40 +00:00
|
|
|
% if domain_aliases and not force_domain:
|
|
|
|
server_name ${domain} ${' '.join(sorted(domain_aliases))};
|
|
|
|
% else:
|
2024-02-13 12:57:53 +00:00
|
|
|
server_name ${domain};
|
2024-02-13 13:01:40 +00:00
|
|
|
% endif
|
2024-02-13 12:57:53 +00:00
|
|
|
|
|
|
|
root ${webroot if webroot else '/var/www/{}/'.format(vhost)};
|
|
|
|
index ${' '.join(index)};
|
|
|
|
|
2024-04-24 21:04:06 +00:00
|
|
|
listen 443 ssl;
|
|
|
|
listen [::]:443 ssl;
|
|
|
|
http2 on;
|
2024-02-13 12:57:53 +00:00
|
|
|
|
|
|
|
% if ssl == 'letsencrypt':
|
|
|
|
ssl_certificate /var/lib/dehydrated/certs/${domain}/fullchain.pem;
|
|
|
|
ssl_certificate_key /var/lib/dehydrated/certs/${domain}/privkey.pem;
|
|
|
|
% else:
|
|
|
|
ssl_certificate /etc/nginx/ssl/${vhost}.crt;
|
|
|
|
ssl_certificate_key /etc/nginx/ssl/${vhost}.key;
|
|
|
|
% endif
|
|
|
|
ssl_dhparam /etc/ssl/certs/dhparam.pem;
|
|
|
|
ssl_protocols TLSv1.2 TLSv1.3;
|
|
|
|
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
|
|
|
|
ssl_prefer_server_ciphers on;
|
|
|
|
ssl_session_cache shared:SSL:10m;
|
|
|
|
ssl_session_tickets off;
|
|
|
|
|
2020-09-20 13:46:39 +00:00
|
|
|
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains";
|
2020-09-20 12:36:43 +00:00
|
|
|
% endif
|
2020-07-19 10:10:19 +00:00
|
|
|
|
|
|
|
resolver 8.8.8.8 8.8.4.4 valid=300s;
|
|
|
|
resolver_timeout 5s;
|
2020-06-01 08:52:52 +00:00
|
|
|
|
2023-09-01 03:53:37 +00:00
|
|
|
% if create_logs:
|
2021-06-05 13:53:02 +00:00
|
|
|
access_log /var/log/nginx/access-${vhost}.log gdpr;
|
2023-09-01 03:53:37 +00:00
|
|
|
error_log /var/log/nginx/error-${vhost}.log;
|
|
|
|
% else:
|
|
|
|
# regular access_log is disabled
|
|
|
|
# error_log is disabled
|
2021-06-05 13:53:02 +00:00
|
|
|
% endif
|
2023-08-26 15:21:23 +00:00
|
|
|
% if create_timing_log:
|
2021-06-05 13:53:02 +00:00
|
|
|
access_log /var/log/nginx-timing/${vhost}.log anon_timing;
|
2023-08-26 15:21:23 +00:00
|
|
|
% endif
|
2021-06-05 13:53:02 +00:00
|
|
|
|
2021-03-30 19:26:25 +00:00
|
|
|
% if max_body_size:
|
|
|
|
client_max_body_size ${max_body_size};
|
|
|
|
% endif
|
|
|
|
|
2020-07-19 09:26:12 +00:00
|
|
|
% if not do_not_set_content_security_headers:
|
2020-06-01 09:31:13 +00:00
|
|
|
add_header Referrer-Policy same-origin;
|
2020-08-18 13:07:43 +00:00
|
|
|
add_header X-Frame-Options "SAMEORIGIN";
|
2020-06-01 09:31:13 +00:00
|
|
|
add_header X-Content-Type-Options nosniff;
|
2021-01-24 17:44:13 +00:00
|
|
|
add_header X-XSS-Protection "1; mode=block";
|
2020-07-19 09:26:12 +00:00
|
|
|
% endif
|
2021-04-16 16:36:50 +00:00
|
|
|
add_header Permissions-Policy interest-cohort=();
|
2020-06-01 08:52:52 +00:00
|
|
|
|
2021-08-07 19:59:07 +00:00
|
|
|
error_page 404 /not_found.html;
|
|
|
|
location = /not_found.html {
|
|
|
|
root /var/www/;
|
|
|
|
internal;
|
|
|
|
}
|
2021-08-07 20:01:40 +00:00
|
|
|
|
2021-08-07 19:59:07 +00:00
|
|
|
error_page 500 502 503 504 /error.html;
|
|
|
|
location = /error.html {
|
|
|
|
root /var/www/;
|
|
|
|
internal;
|
|
|
|
}
|
2021-08-07 19:52:39 +00:00
|
|
|
|
2021-07-01 14:04:46 +00:00
|
|
|
% if ssl == 'letsencrypt':
|
2020-06-01 09:16:22 +00:00
|
|
|
location /.well-known/acme-challenge/ {
|
|
|
|
alias /var/lib/dehydrated/acme-challenges/;
|
|
|
|
}
|
2021-07-01 14:04:46 +00:00
|
|
|
% endif
|
2020-06-01 09:16:22 +00:00
|
|
|
|
2021-06-03 16:56:28 +00:00
|
|
|
% if security_txt:
|
|
|
|
location = /.well-known/security.txt {
|
|
|
|
alias /etc/nginx/security.txt.d/${vhost};
|
|
|
|
}
|
|
|
|
% endif
|
|
|
|
|
2021-07-04 17:27:12 +00:00
|
|
|
% if locations:
|
|
|
|
% for location, options in sorted(locations.items()):
|
2020-06-01 09:31:13 +00:00
|
|
|
location ${location} {
|
2021-07-04 17:27:12 +00:00
|
|
|
% if 'target' in options:
|
2020-09-22 16:36:10 +00:00
|
|
|
proxy_pass ${options['target']};
|
|
|
|
proxy_http_version ${options.get('http_version', '1.1')};
|
2020-08-19 19:43:37 +00:00
|
|
|
proxy_set_header Host ${domain};
|
2021-07-04 17:27:12 +00:00
|
|
|
% if options.get('websockets', False):
|
2020-09-22 16:36:10 +00:00
|
|
|
proxy_set_header Connection "upgrade";
|
|
|
|
proxy_set_header Upgrade $http_upgrade;
|
2021-07-04 17:27:12 +00:00
|
|
|
% endif
|
2020-06-01 09:31:13 +00:00
|
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
2021-09-14 18:21:12 +00:00
|
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
2021-07-04 18:03:22 +00:00
|
|
|
proxy_set_header X-Forwarded-Host ${options.get('x_forwarded_host', domain)};
|
2021-07-04 17:27:12 +00:00
|
|
|
% for option, value in options.get('proxy_set_header', {}).items():
|
2020-09-22 16:36:10 +00:00
|
|
|
proxy_set_header ${option} ${value};
|
2021-07-04 17:27:12 +00:00
|
|
|
% endfor
|
|
|
|
% if location != '/':
|
2020-09-22 16:36:10 +00:00
|
|
|
proxy_set_header X-Script-Name ${location};
|
2021-07-04 17:27:12 +00:00
|
|
|
% endif
|
2020-06-01 09:31:13 +00:00
|
|
|
proxy_buffering off;
|
2021-08-07 18:02:57 +00:00
|
|
|
proxy_read_timeout ${options.get('proxy_read_timeout', 60)};
|
2022-10-19 13:24:39 +00:00
|
|
|
client_max_body_size ${options.get('max_body_size', '5m')};
|
2021-07-04 17:27:12 +00:00
|
|
|
% elif 'redirect' in options:
|
2021-08-22 05:20:45 +00:00
|
|
|
return ${options.get('mode', 308)} ${options['redirect']};
|
2021-07-04 17:27:12 +00:00
|
|
|
% elif 'return' in options:
|
2022-08-19 05:26:01 +00:00
|
|
|
% if options.get('content'):
|
|
|
|
return ${options['return']} '${options['content']}';
|
|
|
|
% else:
|
|
|
|
return ${options['return']};
|
|
|
|
% endif
|
2021-07-04 17:27:12 +00:00
|
|
|
% elif 'root' in options:
|
|
|
|
root ${options['root']};
|
|
|
|
% elif 'alias' in options:
|
|
|
|
alias ${options['alias']};
|
|
|
|
% endif
|
|
|
|
% if 'auth' in options:
|
|
|
|
auth_basic "${options['auth'].get('realm', vhost)}";
|
|
|
|
auth_basic_user_file ${options['auth']['file']};
|
|
|
|
% endif
|
|
|
|
% for opt in sorted(options.get('additional_config', set())):
|
|
|
|
${opt};
|
|
|
|
% endfor
|
2020-06-01 09:31:13 +00:00
|
|
|
}
|
|
|
|
|
2021-07-04 17:27:12 +00:00
|
|
|
% endfor
|
|
|
|
% endif
|
2020-07-19 09:09:53 +00:00
|
|
|
% if php:
|
2023-09-02 18:49:05 +00:00
|
|
|
location ~ \.php(?:$|/) {
|
2020-10-31 12:00:38 +00:00
|
|
|
include fastcgi.conf;
|
|
|
|
fastcgi_pass unix:/run/php/php${php_version}-fpm.sock;
|
2023-09-02 18:49:05 +00:00
|
|
|
% if not do_not_set_content_security_headers:
|
|
|
|
fastcgi_hide_header Referrer-Policy;
|
|
|
|
fastcgi_hide_header X-Frame-Options;
|
|
|
|
fastcgi_hide_header X-Content-Type-Options;
|
|
|
|
fastcgi_hide_header X-XSS-Protection;
|
|
|
|
% endif
|
|
|
|
fastcgi_hide_header Permissions-Policy;
|
2020-07-19 09:09:53 +00:00
|
|
|
}
|
2021-07-04 17:27:12 +00:00
|
|
|
% if not max_body_size:
|
|
|
|
client_max_body_size 5M;
|
|
|
|
% endif
|
2020-07-19 09:09:53 +00:00
|
|
|
|
2021-07-04 17:27:12 +00:00
|
|
|
% endif
|
2020-06-01 08:52:52 +00:00
|
|
|
% if extras:
|
2020-10-31 12:00:38 +00:00
|
|
|
<%include file="extras/${node.name}/${vhost}" />
|
2020-06-01 08:52:52 +00:00
|
|
|
% endif
|
|
|
|
}
|