59 lines
1.7 KiB
Plaintext
59 lines
1.7 KiB
Plaintext
# TODO: replace <DOMAIN>, <EXTRA-DOMAINS>, and <DIRECTORY>.
|
|
# in vim use """:%s/<DIRECTORY>/replacement/g"""
|
|
|
|
# CORS (1 of 2), allow my sites access to each other
|
|
map $http_origin $allow_origin {
|
|
~^https://(.*\.)?digitaladapt.com$ $http_origin;
|
|
default 'null';
|
|
}
|
|
|
|
server {
|
|
listen 443 ssl http2;
|
|
listen [::]:443 ssl http2;
|
|
|
|
ssl_certificate /etc/letsencrypt/live/<DOMAIN>/fullchain.pem; # managed by Certbot
|
|
ssl_certificate_key /etc/letsencrypt/live/<DOMAIN>/privkey.pem; # managed by Certbot
|
|
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
|
|
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
|
|
|
|
root /var/www/<DIRECTORY>;
|
|
|
|
index index.html index.php;
|
|
|
|
server_name <DOMAIN> <EXTRA-DOMAINS>;
|
|
|
|
server_tokens off; # prevent nginx server detection
|
|
|
|
# restrict access to git folder
|
|
location ~ /\.git {
|
|
return 404;
|
|
}
|
|
|
|
location / {
|
|
# CORS (2 of 2), allow my sites access to each other
|
|
# $allow_origin is created by map above, will only allow my domain access
|
|
# block and replace the CORS header, to permit cross-site use
|
|
proxy_hide_header 'access-control-allow-origin';
|
|
add_header 'access-control-allow-origin' "$allow_origin" always;
|
|
add_header 'access-control-allow-credentials' 'true' always;
|
|
|
|
try_files $uri $uri/ =404;
|
|
}
|
|
|
|
error_page 404 /404.html;
|
|
|
|
access_log /var/log/nginx/<DOMAIN>.access.log tabbed_detailed;
|
|
}
|
|
server {
|
|
listen 80;
|
|
listen [::]:80;
|
|
|
|
server_name <DOMAIN> <EXTRA-DOMAINS>;
|
|
|
|
server_tokens off; # prevent nginx server detection
|
|
|
|
return 301 https://$server_name$request_uri;
|
|
|
|
access_log /var/log/nginx/http.access.log tabbed_detailed;
|
|
}
|