[Auto-Sync] Atualização das configurações em srvproxy001.itguys.com.br - 2025-09-27 13:12:45
This commit is contained in:
parent
6f4bc25f9c
commit
6856b877b9
136
nginx/nginx.conf
136
nginx/nginx.conf
|
|
@ -1,9 +1,20 @@
|
|||
# ==============================================================================
|
||||
# ARQUIVO DE CONFIGURAÇÃO GLOBAL NGINX (VERSÃO MINIMALISTA)
|
||||
# ==============================================================================
|
||||
# AUTOR: Gemini (Especialista NGINX)
|
||||
# DATA DA ALTERAÇÃO: 27/09/2025
|
||||
#
|
||||
# --- DESCRIÇÃO ---
|
||||
# Esta configuração é intencionalmente mínima. Ela define apenas as diretivas
|
||||
# que, por arquitetura do NGINX, devem existir no escopo global 'http'.
|
||||
# Todas as políticas de SSL, compressão, segurança e timeouts devem ser
|
||||
# declaradas explicitamente em cada arquivo de configuração de site.
|
||||
# ==============================================================================
|
||||
|
||||
user www-data;
|
||||
worker_processes auto;
|
||||
worker_rlimit_nofile 65535;
|
||||
pid /run/nginx.pid;
|
||||
error_log /var/log/nginx/error.log;
|
||||
include /etc/nginx/modules-enabled/*.conf;
|
||||
|
||||
events {
|
||||
worker_connections 16384;
|
||||
|
|
@ -11,8 +22,16 @@ events {
|
|||
}
|
||||
|
||||
http {
|
||||
proxy_headers_hash_bucket_size 128;
|
||||
#Configuraçoes de Cache
|
||||
# --- Configurações Globais Mínimas ---
|
||||
sendfile on;
|
||||
tcp_nopush on;
|
||||
server_tokens off; # Padrão de segurança básico
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
ssl_session_cache shared:SSL:10m; # Otimização de sessão SSL
|
||||
|
||||
# --- DEFINIÇÃO DAS ZONAS DE CACHE (OBRIGATÓRIO AQUI) ---
|
||||
# Declara todas as zonas de cache disponíveis para os sites.
|
||||
proxy_cache_path /var/cache/nginx/zabbix_cache levels=1:2 keys_zone=zabbix_cache:10m max_size=1g inactive=60m use_temp_path=off;
|
||||
proxy_cache_path /var/cache/nginx/api_cache levels=1:2 keys_zone=api_cache:10m max_size=100m inactive=5m use_temp_path=off;
|
||||
proxy_cache_path /var/cache/nginx/exchange_private_cache levels=1:2 keys_zone=exchange_private_cache:20m max_size=500m inactive=10m use_temp_path=off;
|
||||
|
|
@ -27,80 +46,53 @@ http {
|
|||
proxy_cache_path /var/cache/nginx/grafana_cache levels=1:2 keys_zone=grafana_cache:10m inactive=60m max_size=1g;
|
||||
proxy_cache_path /var/cache/nginx/technitium_cache levels=1:2 keys_zone=technitium_cache:10m inactive=60m max_size=1g;
|
||||
proxy_cache_path /var/cache/nginx/unifi_cache levels=1:2 keys_zone=unifi_cache:10m inactive=60m max_size=1g;
|
||||
proxy_cache_path /var/cache/nginx/nextcloud_cache_grupopralog levels=1:2 keys_zone=nextcloud_cache:20m max_size=2g inactive=120m use_temp_path=off;
|
||||
|
||||
##
|
||||
# Basic Settings
|
||||
##
|
||||
sendfile on;
|
||||
tcp_nopush on;
|
||||
types_hash_max_size 2048;
|
||||
server_tokens off;
|
||||
|
||||
# server_names_hash_bucket_size 64;
|
||||
# server_name_in_redirect off;
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
|
||||
##
|
||||
# Otimizações de Proxy Reverso e Buffers
|
||||
##
|
||||
client_body_buffer_size 128k;
|
||||
client_max_body_size 10G; # Ajuste conforme a necessidade de upload da sua aplicação
|
||||
proxy_buffer_size 16k;
|
||||
proxy_buffers 8 16k;
|
||||
proxy_busy_buffers_size 32k;
|
||||
|
||||
# Otimizações de Keep-Alive e Timeouts
|
||||
##
|
||||
keepalive_timeout 65s;
|
||||
keepalive_requests 1000; # Número de requests por conexão keep-alive
|
||||
send_timeout 10s; # Tempo para o backend responder
|
||||
|
||||
# Ativa o ModSecurity e aponta para o arquivo de configuração
|
||||
modsecurity on;
|
||||
modsecurity_rules_file /etc/nginx/modsecurity.conf;
|
||||
modsecurity_rules_file /etc/nginx/modsecurity/global-exceptions.conf;
|
||||
|
||||
##
|
||||
# SSL Settings
|
||||
##
|
||||
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # Dropping SSLv3, ref: POODLE
|
||||
ssl_prefer_server_ciphers on;
|
||||
|
||||
# Configurações do GeoIP2
|
||||
##
|
||||
geoip2 /usr/share/GeoIP/GeoLite2-City.mmdb {
|
||||
$geoip2_country_code country iso_code;
|
||||
$geoip2_country_name country names en;
|
||||
$geoip2_region_name subdivisions 0 names en;
|
||||
$geoip2_city_name city names en;
|
||||
$geoip2_latitude location latitude;
|
||||
$geoip2_longitude location longitude;
|
||||
$geoip2_asn autonomous_system_number;
|
||||
$geoip2_isp autonomous_system_organization;
|
||||
# --- DEFINIÇÃO DE CAPACIDADES DE SEGURANÇA (OBRIGATÓRIO AQUI) ---
|
||||
# Define as 'variáveis' e 'zonas' que os sites podem usar para segurança.
|
||||
map $http_user_agent $is_bad_bot {
|
||||
default 0;
|
||||
~*(nikto|sqlmap|wpscan|gobuster|dirbuster|feroxbuster|nessus|nmap|curl) 1;
|
||||
}
|
||||
|
||||
geoip2 /usr/share/GeoIP/GeoLite2-ASN.mmdb {
|
||||
$geoip2_asn autonomous_system_number;
|
||||
$geoip2_isp autonomous_system_organization;
|
||||
map $request_uri $is_suspicious_uri {
|
||||
default 0;
|
||||
~*(\.env|\.git|/vendor/|/setup\.php|/\.well-known/|/phpmyadmin|/config\.php|composer\.json) 1;
|
||||
}
|
||||
map $is_bad_bot$is_suspicious_uri $block_request {
|
||||
default 0;
|
||||
~1 1;
|
||||
}
|
||||
geo $is_internal {
|
||||
default 0;
|
||||
10.10.0.0/16 1; 10.11.0.0/16 1; 10.12.0.0/16 1; 172.16.0.0/16 1;
|
||||
45.169.73.155 1; 201.73.213.130 1; 177.74.160.17 1; 177.74.160.18 1;
|
||||
177.74.160.19 1; 177.74.160.20 1; 177.74.160.21 1; 177.74.160.22 1;
|
||||
177.74.160.23 1; 45.169.87.168 1; 45.169.87.169 1; 45.169.87.170 1;
|
||||
45.169.87.171 1; 45.169.87.172 1; 45.169.87.173 1; 45.169.87.174 1;
|
||||
45.169.87.175 1;
|
||||
}
|
||||
map $is_internal $limit_key {
|
||||
0 $binary_remote_addr;
|
||||
1 "";
|
||||
}
|
||||
limit_req_zone $limit_key zone=global_limit:20m rate=10r/s;
|
||||
|
||||
##
|
||||
# Logging Settings
|
||||
##
|
||||
log_format detailed_proxy escape=json '{"@timestamp":"$time_iso8601","remote_addr":"$remote_addr","remote_user":"$remote_user","request":"$request","method":"$request_method","uri":"$uri","args":"$args","status":$status,"request_length":$request_length,"body_bytes_sent":$body_bytes_sent,"request_time":"$request_time","upstream_addr":"$upstream_addr","upstream_status":"$upstream_status","upstream_response_time":"$upstream_response_time","http_referer":"$http_referer","http_user_agent":"$http_user_agent","http_x_forwarded_for":"$http_x_forwarded_for","http_accept_language":"$http_accept_language","http_cookie":"$http_cookie","http_origin":"$http_origin","http_host":"$http_host","server_name":"$server_name","scheme":"$scheme","ssl_protocol":"$ssl_protocol","ssl_cipher":"$ssl_cipher","ssl_curves":"$ssl_curves","ssl_session_reused":"$ssl_session_reused","ssl_server_name":"$ssl_server_name","ssl_client_s_dn":"$ssl_client_s_dn","ssl_client_i_dn":"$ssl_client_i_dn","ssl_client_verify":"$ssl_client_verify","ssl_client_serial":"$ssl_client_serial","ssl_client_v_start":"$ssl_client_v_start","ssl_client_v_end":"$ssl_client_v_end","geoip_country_code":"$geoip2_country_code","geoip_country_name":"$geoip2_country_name","geoip_region_name":"$geoip2_region_name","geoip_city_name":"$geoip2_city_name","geoip_latitude":"$geoip2_latitude","geoip_longitude":"$geoip2_longitude","geoip_asn":"$geoip2_asn","geoip_isp":"$geoip2_isp"}';
|
||||
access_log /var/log/nginx/access.log detailed_proxy;
|
||||
# DIRETIVA DE LOG GLOBAL
|
||||
# Todas as requisições de todos os sites serão salvas aqui neste formato, por padrão.
|
||||
# --- DEFINIÇÃO DO FORMATO DE LOG (OBRIGATÓRIO AQUI) ---
|
||||
# Define um formato de log rico que pode ser chamado por qualquer site.
|
||||
log_format detailed_proxy escape=json '{"@timestamp":"$time_iso8601","remote_addr":"$remote_addr",'
|
||||
'"request":"$request","status":$status,"body_bytes_sent":$body_bytes_sent,"request_time":"$request_time",'
|
||||
'"upstream_addr":"$upstream_addr","upstream_status":"$upstream_status","upstream_response_time":"$upstream_response_time",'
|
||||
'"http_referer":"$http_referer","http_user_agent":"$http_user_agent","http_x_forwarded_for":"$http_x_forwarded_for",'
|
||||
'"server_name":"$server_name","scheme":"$scheme","ssl_protocol":"$ssl_protocol","ssl_cipher":"$ssl_cipher",'
|
||||
'"geoip_country_code":"$geoip2_country_code","geoip_city_name":"$geoip2_city_name","geoip_isp":"$geoip2_isp",'
|
||||
'"block_request":"$block_request"}';
|
||||
|
||||
##
|
||||
# Gzip Settings
|
||||
##
|
||||
include /etc/nginx/snippets/compression_params.conf;
|
||||
# --- LOGS GLOBAIS DE FALLBACK ---
|
||||
# Logs mínimos para requisições que não correspondem a nenhum 'server' block.
|
||||
error_log /var/log/nginx/error.log warn;
|
||||
access_log /var/log/nginx/access.log;
|
||||
|
||||
##
|
||||
# Virtual Host Configs
|
||||
##
|
||||
# --- Inclusão dos Arquivos de Configuração de Sites ---
|
||||
include /etc/nginx/conf.d/*.conf;
|
||||
include /etc/nginx/sites-enabled/*;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue