Initial Commit

This commit is contained in:
fernao
2020-06-17 13:31:05 -03:00
parent 922c46e64c
commit 68e9f5900b
14 changed files with 864 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
### gzip + compression global rules
### to be included a single time throughout this nginx instance
### headers rules are also consolidated here
gzip on;
gzip_disable "msie6";
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_min_length 1100;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
# Enable HSTS. This forces SSL on clients that respect it, most modern browsers. The includeSubDomains flag is optional.
add_header Strict-Transport-Security "max-age=31536000;includeSubDomains";
## Header hardening
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";

7
nginx/extra/php-fpm.conf Normal file
View File

@@ -0,0 +1,7 @@
location ~ \.php$ {
include fastcgi_params;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_pass unix:/run/php-fpm/php-fpm.sock;
}

View File

@@ -0,0 +1,39 @@
# Global restrictions configuration file
# Designed to be included in any server {} block
## Disable TRACE, DELETE, PUT, OPTIONS modes
if ($request_method !~ ^(GET|HEAD|POST)$ ) {
return 405;
}
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
# Deny all attempts to access hidden files such as .htaccess, .htpasswd, .DS_Store (Mac).
# Keep logging the requests to parse later (or to pass to firewall utilities such as fail2ban)
location ~ /\. {
access_log off;
log_not_found off;
deny all;
}
location ~* \.(jpg|jpeg|gif|png|css|js|ico|xml)$ {
access_log off;
log_not_found off;
expires 360d;
}
# Deny access to any files with a .php extension in the uploads directory
# Works in sub-directory installs and also in multisite network
# Keep logging the requests to parse later (or to pass to firewall utilities such as fail2ban)
location ~* /(?:uploads|files)/.*\.php$ {
deny all;
}

25
nginx/nginx.conf Normal file
View File

@@ -0,0 +1,25 @@
user http;
worker_processes 4;
#pid /run/nginx.pid;
events {
worker_connections 2048;
}
http {
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
types_hash_bucket_size 128;
server_tokens off;
default_type application/octet-stream;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
include /etc/nginx/extra/headers-gzip.conf;
include /etc/nginx/mime.types;
include /etc/nginx/sites-enabled/*;
}

View File

@@ -0,0 +1,43 @@
server {
listen 80;
server_name CHANGE-ME;
rewrite ^(.*) https://****CHANGE-ME****$1 permanent;
}
server {
server_name CHANGE-ME.lan.uw;
access_log /var/log/nginx/CHANGE-ME_access.log;
error_log /var/log/nginx/CHANGE-ME_error.log;
index index.html index.php index.htm;
include /etc/nginx/ssl/default.conf;
include /etc/nginx/extra/php-fpm.conf;
include /etc/nginx/extra/restrictions.conf;
root /var/www/CHANGE-ME;
location / {
try_files $uri $uri/ /index.php;
location ~ \.php$ {
include fastcgi_params;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_pass unix:/run/php-fpm/php-fpm.sock;
}
}
# Static site subfolders
# include /etc/nginx/subfolders/hugo.conf;
# include /etc/nginx/subfolders/sphinx.conf;
# PHP applications
# include /etc/nginx/subfolders/wordpress.conf;
# include /etc/nginx/subfolders/nextcloud.conf;
# include /etc/nginx/subfolders/phpmyadmin.conf;
# include /etc/nginx/subfolders/phpredisadmin.conf;
# include /etc/nginx/subfolders/php-vbox.conf;
# include /etc/nginx/subfolders/phppgadmin.conf;
# include /etc/nginx/subfolders/postfixadmin.conf;
} ## end server block ##

17
nginx/ssl/default.conf Normal file
View File

@@ -0,0 +1,17 @@
# listens both on IPv4 and IPv6 on 443 and enables HTTPS and HTTP/2 support.
# HTTP/2 is available in nginx 1.9.5 and above.
listen *:443 ssl http2;
#listen [::]:443 ssl http2;
##ssl on; ## deprecated
ssl_session_cache shared:SSL:20m;
ssl_session_timeout 10m;
ssl_protocols TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_certificate /etc/nginx/ssl/server.crt;
ssl_certificate_key /etc/nginx/ssl/server.key;
ssl_dhparam /etc/nginx/ssl/dhparams.pem;
ssl_ciphers 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384: DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:CAMELLIA:!DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!CBC:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA';

View File

@@ -0,0 +1,16 @@
#### PHP MY ADMIN SUBFOLDER ####
location /phpmyadmin {
alias /usr/share/webapps/phpMyAdmin;
try_files $uri $uri/ @pma;
index index.php;
access_log /var/log/nginx/phpmyadmin_access.log;
error_log /var/log/nginx/phpmyadmin_error.log;
include /etc/nginx/extra/php-fpm.conf;
location ~ ^/phpmyadmin/(.*\.(js|css|gif|jpg|png|ico))$ {
alias /usr/share/webapps/phpMyAdmin/$1;
}
}
location @pma { rewrite /phpmyadmin/(.*)$ /phpmyadmin$request_uri last; }

View File

@@ -0,0 +1,16 @@
#### PHP POSTGRES ADMIN SUBFOLDER ####
location /phppgadmin {
alias /usr/share/webapps/phppgadmin;
try_files $uri $uri/ @ppg;
index index.php;
access_log /var/log/nginx/phppgadmin_access.log;
error_log /var/log/nginx/phppgadmin_error.log;
include /etc/nginx/extra/php-fpm.conf;
location ~ ^/phppgadmin/(.*\.(js|css|gif|jpg|png|ico))$ {
alias /usr/share/webapps/phppgadmin/$1;
}
}
location @ppg { rewrite /phppgadmin/(.*)$ /phppgadmin$request_uri last; }

View File

@@ -0,0 +1,16 @@
#### PHP REDIS ADMIN SUBFOLDER ####
location /phpredisadmin {
alias /usr/share/webapps/phpRedisAdmin;
try_files $uri $uri/ @pra;
index index.php;
access_log /var/log/nginx/phpredisadmin_access.log;
error_log /var/log/nginx/phpredisadmin_error.log;
include /etc/nginx/extra/php-fpm.conf;
location ~ ^/phpredisadmin/(.*\.(js|css|gif|jpg|png|ico))$ {
alias /usr/share/webapps/phpRedisAdmin/$1;
}
}
location @pra { rewrite /phpredisadmin/(.*)$ /phpredisadmin$request_uri last; }