updated nginx examples
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
# 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;
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
# TODO: replace <DOMAIN>, <EXTRA-DOMAINS>, and <DIRECTORY>.
|
||||
# in vim use """:%s/<DIRECTORY>/replacement/g"""
|
||||
|
||||
server {
|
||||
listen 443 ssl http2 default_server;
|
||||
listen [::]:443 ssl http2 ipv6only=on default_server;
|
||||
@@ -24,20 +25,16 @@ server {
|
||||
|
||||
# optional, enforce primary domain
|
||||
#if ($host != $server_name) {
|
||||
# return 301 $scheme://$server_name$request_uri;
|
||||
# return 301 https://$server_name$request_uri;
|
||||
#}
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ =404;
|
||||
}
|
||||
|
||||
location ~ \.php$ {
|
||||
# location ~ \.php(/|$) {
|
||||
include snippets/fastcgi-php.conf;
|
||||
fastcgi_pass unix:/run/php/php8.1-fpm.sock;
|
||||
}
|
||||
|
||||
error_page 404 /404.html;
|
||||
|
||||
access_log /var/log/nginx/<DOMAIN>.access.log tabbed_detailed;
|
||||
}
|
||||
server {
|
||||
listen 80 default_server;
|
||||
@@ -48,4 +45,6 @@ server {
|
||||
server_tokens off; # prevent nginx server detection
|
||||
|
||||
return 301 https://$server_name$request_uri;
|
||||
|
||||
access_log /var/log/nginx/http.access.log tabbed_detailed;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
# TODO: replace <DOMAIN>, <EXTRA-DOMAINS>, and <DIRECTORY>.
|
||||
# in vim use """:%s/<DIRECTORY>/replacement/g"""
|
||||
|
||||
server {
|
||||
listen 443 ssl http2;
|
||||
listen [::]:443 ssl http2;
|
||||
@@ -22,22 +23,13 @@ server {
|
||||
return 404;
|
||||
}
|
||||
|
||||
# optional, enforce primary domain
|
||||
#if ($host != $server_name) {
|
||||
# return 301 $scheme://$server_name$request_uri;
|
||||
#}
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ =404;
|
||||
}
|
||||
|
||||
location ~ \.php$ {
|
||||
# location ~ \.php(/|$) {
|
||||
include snippets/fastcgi-php.conf;
|
||||
fastcgi_pass unix:/run/php/php8.1-fpm.sock;
|
||||
}
|
||||
|
||||
error_page 404 /404.html;
|
||||
|
||||
access_log /var/log/nginx/<DOMAIN>.access.log tabbed_detailed;
|
||||
}
|
||||
server {
|
||||
listen 80;
|
||||
@@ -48,4 +40,6 @@ server {
|
||||
server_tokens off; # prevent nginx server detection
|
||||
|
||||
return 301 https://$server_name$request_uri;
|
||||
|
||||
access_log /var/log/nginx/http.access.log tabbed_detailed;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
# TODO: replace <DOMAIN>, <EXTRA-DOMAINS>, and <DIRECTORY>.
|
||||
# in vim use """:%s/<DIRECTORY>/replacement/g"""
|
||||
|
||||
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 / {
|
||||
try_files $uri $uri/ =404;
|
||||
}
|
||||
|
||||
location ~ \.php$ {
|
||||
# location ~ \.php(/|$) {
|
||||
include snippets/fastcgi-php.conf;
|
||||
fastcgi_pass unix:/run/php/php8.1-fpm.sock;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
Reference in New Issue
Block a user