This commit is contained in:
temasky
2020-07-31 12:45:56 +00:00
commit 5d419635ed
306 changed files with 26949 additions and 0 deletions
@@ -0,0 +1 @@
map_hash_bucket_size 1024;
@@ -0,0 +1,8 @@
map $sent_http_content_type $expires {
default off;
application/x-javascript 1d;
text/css 1d;
~image/ 1d;
}
expires $expires;
@@ -0,0 +1 @@
client_max_body_size 12m;
@@ -0,0 +1 @@
default_type application/octet-stream;
@@ -0,0 +1,10 @@
gzip on;
gzip_vary on;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_min_length 10240;
gzip_proxied expired no-cache no-store private auth;
gzip_types text/plain text/css text/xml text/javascript text/json application/json application/x-javascript application/xml application/xml+rss;
gzip_disable "MSIE [1-6]\.";
@@ -0,0 +1,7 @@
add_header X-Frame-Options sameorigin;
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection '1; mode=block';
add_header X-Download-Options noopen;
add_header X-Permitted-Cross-Domain-Policies none;
add_header Content-Security-Policy "default-src https: data: 'unsafe-inline' 'unsafe-eval'";
add_header Referrer-Policy strict-origin;
@@ -0,0 +1,2 @@
access_log PH_NGINX_LOG_ACCESSLOG;
error_log PH_NGINX_LOG_ERRORLOG;
@@ -0,0 +1 @@
include PH_NGINX_MIME_TYPES;
@@ -0,0 +1,3 @@
upstream php_workers {
server PH_PHP_FPM_BIND_HOST:PH_PHP_FPM_PORT;
}
@@ -0,0 +1 @@
sendfile on;
@@ -0,0 +1,2 @@
# Hide Nginx version number
server_tokens off;
@@ -0,0 +1 @@
types_hash_max_size 2048;
+12
View File
@@ -0,0 +1,12 @@
user PH_HTTPD_USER;
worker_processes 1;
pid PH_NGINX_PID;
events {
worker_connections 1024;
}
http {
include PH_HTTPD_CONF_DIR_ENABLED_CONF/*.conf;
include PH_HTTPD_CONF_DIR_ENABLED_SITES/*.conf;
}
@@ -0,0 +1,21 @@
#
# Note: This file must be loaded before other virtual host config files,
#
# HTTPS
server {
listen PH_HTTPS_PORT ssl;
#listen [::]:PH_HTTPS_PORT ssl;
server_name _;
root PH_HTTPD_DOCUMENTROOT;
index index.php index.html;
include PH_NGINX_CONF_TMPL_DIR/misc.tmpl;
include PH_NGINX_CONF_TMPL_DIR/ssl.tmpl;
include PH_NGINX_CONF_TMPL_DIR/iredadmin.tmpl;
include PH_NGINX_CONF_TMPL_DIR/roundcube.tmpl;
include PH_NGINX_CONF_TMPL_DIR/sogo.tmpl;
include PH_NGINX_CONF_TMPL_DIR/netdata.tmpl;
include PH_NGINX_CONF_TMPL_DIR/php-catchall.tmpl;
include PH_NGINX_CONF_TMPL_DIR/stub_status.tmpl;
}
@@ -0,0 +1,14 @@
#
# Note: This file must be loaded before other virtual host config files,
#
# HTTP
server {
# Listen on ipv4
listen PH_PORT_HTTP;
#listen [::]:PH_PORT_HTTP;
server_name _;
# Redirect all insecure http:// requests to https://
return 301 https://$host$request_uri;
}
@@ -0,0 +1,46 @@
# Sample setting for Adminer: http://adminer.org/
# -----------------------------------------
# How to get it working:
#
# mkdir PH_HTTPD_SERVERROOT/adminer
# cd PH_HTTPD_SERVERROOT/adminer
# wget http://www.adminer.org/latest.php
# chmod +x latest.php
#
# Warning: for security concern, it's recommended to change the URL '/adminer'
# to another random string to avoid login attempts from bad guys.
# for example, change the url to '^/HIoWCwogSHukIbGL'.
#
# -----------------------------------------
# If you cannot login to MySQL server as root user:
#
# New MySQL or MariaDB support plugin authentication, by default, the root
# account has setting `user.plugin=unix_socket` (in `mysql` database). The
# `auth_socket` authentication plugin authenticates clients that connect from
# the local host through the Unix socket file, this prevents access via network
# connection, including Adminer. To make it working, please disable this
# authentication plugin with sql commands below:
#
# sql> USE mysql;
# sql> UPDATE user SET plugin='' WHERE User='root';
#
# Refer to MySQL document for more details:
# https://dev.mysql.com/doc/refman/5.7/en/socket-authentication-plugin.html
location ~ ^/adminer$ {
include PH_NGINX_CONF_TMPL_DIR/hsts.tmpl;
include PH_NGINX_CONF_TMPL_DIR/fastcgi_php.tmpl;
fastcgi_param SCRIPT_FILENAME PH_HTTPD_SERVERROOT/adminer/latest.php;
# Access control
#allow 127.0.0.1;
#allow 192.168.1.10;
#allow 192.168.1.0/24;
#deny all;
}
location ~ ^/adminer.css$ {
alias PH_HTTPD_SERVERROOT/adminer/adminer.css;
}
@@ -0,0 +1,17 @@
#
# Template used to handle PHP fastcgi applications
#
# You still need to define `SCRIPT_FILENAME` for your PHP application, and
# probably `fastcgi_index` if your application use different index file.
#
include fastcgi_params;
# Directory index file
fastcgi_index index.php;
# Handle PHP files with upstream handler
fastcgi_pass php_workers;
# Fix the HTTPROXY issue.
# Reference: https://httpoxy.org/
fastcgi_param HTTP_PROXY '';
@@ -0,0 +1,17 @@
# Use HTTP Strict Transport Security to force client to use secure
# connections only. References:
#
# * RFC Document (6797): HTTP Strict Transport Security (HSTS)
# https://tools.ietf.org/html/rfc6797#section-6.1.2
#
# * Short tutorial from Mozilla:
# https://developer.mozilla.org/en-US/docs/Web/Security/HTTP_strict_transport_security
#
# WARNING: According to RFC document, HSTS will fail with self-signed SSL
# certificate.
# https://tools.ietf.org/html/rfc6797#page-27
#
# Syntax:
#
# Strict-Transport-Security: max-age=expireTime [; includeSubDomains] [; preload]
add_header Strict-Transport-Security "max-age=31536000";
@@ -0,0 +1,16 @@
#
# Run iRedAdmin as a sub-domain virtual host.
#
include PH_NGINX_CONF_TMPL_DIR/hsts.tmpl;
location / {
root PH_IREDADMIN_HTTPD_ROOT_SYMBOL_LINK;
uwsgi_pass PH_IREDADMIN_BIND_ADDRESS:PH_IREDADMIN_LISTEN_PORT;
uwsgi_param UWSGI_CHDIR PH_IREDADMIN_HTTPD_ROOT_SYMBOL_LINK;
uwsgi_param UWSGI_SCRIPT iredadmin;
include uwsgi_params;
}
location /static {
alias PH_IREDADMIN_HTTPD_ROOT_SYMBOL_LINK/static;
}
@@ -0,0 +1,35 @@
# Settings for iRedAdmin.
# static files under /iredadmin/static
location ~ ^/iredadmin/static/(.*) {
alias PH_IREDADMIN_HTTPD_ROOT_SYMBOL_LINK/static/$1;
}
# Python scripts
location ~ ^/iredadmin(.*) {
rewrite ^/iredadmin(/.*)$ $1 break;
include PH_NGINX_CONF_TMPL_DIR/hsts.tmpl;
include uwsgi_params;
uwsgi_pass PH_IREDADMIN_BIND_ADDRESS:PH_IREDADMIN_LISTEN_PORT;
uwsgi_param UWSGI_CHDIR PH_IREDADMIN_HTTPD_ROOT_SYMBOL_LINK;
uwsgi_param UWSGI_SCRIPT iredadmin;
uwsgi_param SCRIPT_NAME /iredadmin;
# Access control
#allow 127.0.0.1;
#allow 192.168.1.10;
#allow 192.168.1.0/24;
#deny all;
}
# iRedAdmin: redirect /iredadmin to /iredadmin/
location = /iredadmin {
rewrite ^ /iredadmin/;
}
# Handle newsletter-style subscription/unsubscription supported in iRedAdmin-Pro.
location ~ ^/newsletter/ {
rewrite /newsletter/(.*) /iredadmin/newsletter/$1 last;
}
@@ -0,0 +1,15 @@
# Allow access to '^/.well-known/'
location ~ ^/.well-known/ {
allow all;
access_log off;
log_not_found off;
autoindex off;
#root /var/www/html;
}
# Deny all attempts to access hidden files such as .htaccess.
location ~ /\. { deny all; }
# Handling noisy messages
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
@@ -0,0 +1,22 @@
#
# Run netdata as a sub-domain virtual host.
#
# FYI: https://github.com/firehol/netdata/wiki/Running-behind-nginx
location / {
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:PH_NETDATA_PORT;
proxy_http_version 1.1;
proxy_pass_request_headers on;
proxy_set_header Connection "keep-alive";
proxy_store off;
gzip on;
gzip_proxied any;
gzip_types *;
auth_basic "Authentication Required";
auth_basic_user_file PH_NETDATA_HTTPD_AUTH_FILE;
}
@@ -0,0 +1,27 @@
# Running netdata as a subfolder to an existing virtual host
# FYI: https://github.com/firehol/netdata/wiki/Running-behind-nginx
location = /netdata {
return 301 /netdata/;
}
location ~ /netdata/(?<ndpath>.*) {
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_http_version 1.1;
proxy_pass_request_headers on;
proxy_set_header Connection "keep-alive";
proxy_store off;
proxy_pass http://127.0.0.1:PH_NETDATA_PORT/$ndpath$is_args$args;
gzip on;
gzip_proxied any;
gzip_types *;
auth_basic "Authentication Required";
auth_basic_user_file PH_NETDATA_HTTPD_AUTH_FILE;
}
@@ -0,0 +1,6 @@
# Normal PHP scripts
location ~ \.php$ {
include PH_NGINX_CONF_TMPL_DIR/fastcgi_php.tmpl;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
@@ -0,0 +1,5 @@
# Redirect webmail/SOGo/iredadmin to HTTPS
location ~ ^/mail { rewrite ^ https://$host$request_uri?; }
location ~ ^/mail/index.php$ { rewrite ^ https://$host/mail/; }
location ~* ^/sogo { rewrite ^ https://$host/SOGo; }
location ~ ^/iredadmin { rewrite ^ https://$host$request_uri?; }
@@ -0,0 +1,26 @@
#
# Run Roundcube as a sub-domain virtual host.
#
# Block access to default directories and files under these directories
location ~ ^/(bin|config|installer|logs|SQL|temp|vendor)/.* { deny all; }
# Block access to default files under top-directory and files start with same name.
location ~ ^/(CHANGELOG|composer.json|INSTALL|jsdeps.json|LICENSE|README|UPGRADING)$ { deny all; }
# Block plugin config files and sample config files.
location ~ ^/plugins/.*/config.inc.php.* { deny all; }
# Block access to plugin data
location ~ ^/plugins/enigma/home($|/.*) { deny all; }
location / {
root PH_RCM_HTTPD_ROOT_SYMBOL_LINK;
index index.php index.html;
include PH_NGINX_CONF_TMPL_DIR/hsts.tmpl;
}
location ~ \.php$ {
root PH_RCM_HTTPD_ROOT_SYMBOL_LINK;
include PH_NGINX_CONF_TMPL_DIR/fastcgi_php.tmpl;
fastcgi_param SCRIPT_FILENAME PH_RCM_HTTPD_ROOT_SYMBOL_LINK$fastcgi_script_name;
}
@@ -0,0 +1,30 @@
#
# Running Roundcube as a subfolder on an existing virtual host
#
# Block access to default directories and files under these directories
location ~ ^/mail/(bin|config|installer|logs|SQL|temp|vendor)($|/.*) { deny all; }
# Block access to default files under top-directory and files start with same name.
location ~ ^/mail/(CHANGELOG|composer.json|INSTALL|jsdeps.json|LICENSE|README|UPGRADING)($|.*) { deny all; }
# Block plugin config files and sample config files.
location ~ ^/mail/plugins/.*/config.inc.php.* { deny all; }
# Block access to plugin data
location ~ ^/mail/plugins/enigma/home($|/.*) { deny all; }
# Redirect URI `/mail` to `/mail/`.
location = /mail {
return 301 /mail/;
}
location ~ ^/mail/(.*\.php)$ {
include PH_NGINX_CONF_TMPL_DIR/hsts.tmpl;
include PH_NGINX_CONF_TMPL_DIR/fastcgi_php.tmpl;
fastcgi_param SCRIPT_FILENAME PH_RCM_HTTPD_ROOT_SYMBOL_LINK/$1;
}
location ~ ^/mail/(.*) {
alias PH_RCM_HTTPD_ROOT_SYMBOL_LINK/$1;
index index.php;
}
@@ -0,0 +1,65 @@
#
# Run SOGo as a sub-domain virtual host.
#
root PH_SOGO_GNUSTEP_DIR/WebServerResources;
location / {
rewrite ^ https://$host/SOGo;
}
# For Mac OS X and iOS devices.
rewrite ^/.well-known/caldav /SOGo/dav permanent;
rewrite ^/.well-known/carddav /SOGo/dav permanent;
rewrite ^/principals /SOGo/dav permanent;
include PH_NGINX_CONF_TMPL_DIR/hsts.tmpl;
location ^~ /SOGo {
proxy_pass http://PH_SOGO_BIND_ADDRESS:PH_SOGO_BIND_PORT;
# forward user's IP address
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
# always use https
proxy_set_header x-webobjects-server-port $server_port;
proxy_set_header x-webobjects-server-name $host;
proxy_set_header x-webobjects-server-url https://$host;
proxy_set_header x-webobjects-server-protocol HTTP/1.0;
}
location ^~ /Microsoft-Server-ActiveSync {
proxy_pass http://PH_SOGO_BIND_ADDRESS:PH_SOGO_BIND_PORT/SOGo/Microsoft-Server-ActiveSync;
proxy_connect_timeout PH_SOGO_PROXY_TIMEOUT;
proxy_send_timeout PH_SOGO_PROXY_TIMEOUT;
proxy_read_timeout PH_SOGO_PROXY_TIMEOUT;
}
location ^~ /SOGo/Microsoft-Server-ActiveSync {
proxy_pass http://PH_SOGO_BIND_ADDRESS:PH_SOGO_BIND_PORT/SOGo/Microsoft-Server-ActiveSync;
proxy_connect_timeout PH_SOGO_PROXY_TIMEOUT;
proxy_send_timeout PH_SOGO_PROXY_TIMEOUT;
proxy_read_timeout PH_SOGO_PROXY_TIMEOUT;
}
location /SOGo.woa/WebServerResources/ {
alias PH_SOGO_GNUSTEP_DIR/WebServerResources/;
expires max;
}
location /SOGo/WebServerResources/ {
alias PH_SOGO_GNUSTEP_DIR/WebServerResources/;
expires max;
}
location ^/SOGo/so/ControlPanel/Products/([^/]*)/Resources/(.*)$ {
alias PH_SOGO_GNUSTEP_DIR/$1.SOGo/Resources/$2;
expires max;
}
location (^/SOGo/so/ControlPanel/Products/[^/]*UI/Resources/.*\.(jpg|png|gif|css|js)$) {
alias PH_SOGO_GNUSTEP_DIR/$1.SOGo/Resources/$2;
expires max;
}
@@ -0,0 +1,60 @@
# Settings for SOGo Groupware
# SOGo
location ~ ^/sogo { rewrite ^ https://$host/SOGo; }
location ~ ^/SOGO { rewrite ^ https://$host/SOGo; }
# Redirect /mail to /SOGo
#location ~ ^/mail { rewrite ^ https://$host/SOGo; }
# For Mac OS X and iOS devices.
rewrite ^/.well-known/caldav /SOGo/dav permanent;
rewrite ^/.well-known/carddav /SOGo/dav permanent;
rewrite ^/principals /SOGo/dav permanent;
location ^~ /SOGo {
include PH_NGINX_CONF_TMPL_DIR/hsts.tmpl;
proxy_pass http://PH_SOGO_BIND_ADDRESS:PH_SOGO_BIND_PORT;
# forward user's IP address
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
# always use https
proxy_set_header x-webobjects-server-port $server_port;
proxy_set_header x-webobjects-server-name $host;
proxy_set_header x-webobjects-server-url https://$host;
proxy_set_header x-webobjects-server-protocol HTTP/1.0;
}
location ^~ /Microsoft-Server-ActiveSync {
proxy_pass http://PH_SOGO_BIND_ADDRESS:PH_SOGO_BIND_PORT/SOGo/Microsoft-Server-ActiveSync;
proxy_connect_timeout PH_SOGO_PROXY_TIMEOUT;
proxy_send_timeout PH_SOGO_PROXY_TIMEOUT;
proxy_read_timeout PH_SOGO_PROXY_TIMEOUT;
}
location ^~ /SOGo/Microsoft-Server-ActiveSync {
proxy_pass http://PH_SOGO_BIND_ADDRESS:PH_SOGO_BIND_PORT/SOGo/Microsoft-Server-ActiveSync;
proxy_connect_timeout PH_SOGO_PROXY_TIMEOUT;
proxy_send_timeout PH_SOGO_PROXY_TIMEOUT;
proxy_read_timeout PH_SOGO_PROXY_TIMEOUT;
}
location /SOGo.woa/WebServerResources/ {
alias PH_SOGO_GNUSTEP_DIR/WebServerResources/;
expires max;
}
location /SOGo/WebServerResources/ {
alias PH_SOGO_GNUSTEP_DIR/WebServerResources/;
expires max;
}
location ^/SOGo/so/ControlPanel/Products/([^/]*)/Resources/(.*)$ {
alias PH_SOGO_GNUSTEP_DIR/$1.SOGo/Resources/$2;
expires max;
}
+21
View File
@@ -0,0 +1,21 @@
ssl_protocols TLSv1.2;
# Fix 'The Logjam Attack'.
ssl_ciphers PH_SSL_CIPHERS;
ssl_prefer_server_ciphers on;
ssl_dhparam PH_SSL_DH1024_PARAM_FILE;
# To use your own ssl cert (e.g. "Let's Encrypt"), please create symbol link to
# ssl cert/key used below, so that we can manage this config file with Ansible.
#
# For example:
#
# rm -f PH_SSL_KEY_FILE
# rm -f PH_SSL_CERT_FILE
# ln -s /etc/letsencrypt/live/<domain>/privkey.pem PH_SSL_KEY_FILE
# ln -s /etc/letsencrypt/live/<domain>/fullchain.pem PH_SSL_CERT_FILE
#
# To request free "Let's Encrypt" cert, please check our tutorial:
# https://docs.iredmail.org/letsencrypt.html
ssl_certificate PH_SSL_CERT_FILE;
ssl_certificate_key PH_SSL_KEY_FILE;
@@ -0,0 +1,15 @@
location = /stub_status {
stub_status on;
access_log off;
allow 127.0.0.1;
deny all;
}
location = /status {
include fastcgi_params;
fastcgi_pass php_workers;
fastcgi_param SCRIPT_FILENAME $fastcgi_script_name;
access_log off;
allow 127.0.0.1;
deny all;
}