diff --git a/example-nginx-config/example-cors-nginx.conf b/example-nginx-config/example-cors-nginx.conf new file mode 100644 index 0000000..c8db7b0 --- /dev/null +++ b/example-nginx-config/example-cors-nginx.conf @@ -0,0 +1,58 @@ +# TODO: replace , , and . +# in vim use """:%s//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//fullchain.pem; # managed by Certbot + ssl_certificate_key /etc/letsencrypt/live//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/; + + index index.html index.php; + + server_name ; + + 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/.access.log tabbed_detailed; +} +server { + listen 80; + listen [::]:80; + + server_name ; + + server_tokens off; # prevent nginx server detection + + return 301 https://$server_name$request_uri; + + access_log /var/log/nginx/http.access.log tabbed_detailed; +} diff --git a/example-nginx-config/example-default-nginx.conf b/example-nginx-config/example-default-nginx.conf index 11b35ec..9c821fc 100644 --- a/example-nginx-config/example-default-nginx.conf +++ b/example-nginx-config/example-default-nginx.conf @@ -1,5 +1,6 @@ # TODO: replace , , and . # in vim use """:%s//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/.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; } diff --git a/example-nginx-config/example-nginx.conf b/example-nginx-config/example-nginx.conf index 8961718..3b49145 100644 --- a/example-nginx-config/example-nginx.conf +++ b/example-nginx-config/example-nginx.conf @@ -1,5 +1,6 @@ # TODO: replace , , and . # in vim use """:%s//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/.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; } diff --git a/example-nginx-config/example-php-nginx.conf b/example-nginx-config/example-php-nginx.conf new file mode 100644 index 0000000..64305dc --- /dev/null +++ b/example-nginx-config/example-php-nginx.conf @@ -0,0 +1,51 @@ +# TODO: replace , , and . +# in vim use """:%s//replacement/g""" + +server { + listen 443 ssl http2; + listen [::]:443 ssl http2; + + ssl_certificate /etc/letsencrypt/live//fullchain.pem; # managed by Certbot + ssl_certificate_key /etc/letsencrypt/live//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/; + + index index.html index.php; + + server_name ; + + 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/.access.log tabbed_detailed; +} +server { + listen 80; + listen [::]:80; + + server_name ; + + server_tokens off; # prevent nginx server detection + + return 301 https://$server_name$request_uri; + + access_log /var/log/nginx/http.access.log tabbed_detailed; +}