218 lines
9.5 KiB
Plaintext
218 lines
9.5 KiB
Plaintext
# ----------------------------------------------------------------------
|
|
# Configuração: Nextcloud AIO + Office Online Server (Nativo)
|
|
# Data: 2025-10-25
|
|
# Domínio: verbocloud.itguys.com.br
|
|
#
|
|
# Arquitetura:
|
|
# - Nginx (Este servidor)
|
|
# - Backend AIO: 172.16.253.13:11500 (HTTP)
|
|
# - Backend OOS: 172.16.253.13:80 (HTTPS - Nativo no Windows)
|
|
#
|
|
# ATUALIZAÇÃO:
|
|
# - Adicionado Bloco para Nextcloud Talk (HPB / Push).
|
|
# - Adicionado Micro-cache de API (para otimizar Photos, Deck, Notes, etc.)
|
|
# - Diretórios de cache EXCLUSIVOS para este site.
|
|
# ----------------------------------------------------------------------
|
|
|
|
# ----------------------------------------------------------------------
|
|
# Definições de Cache (EXCLUSIVOS para verbocloud)
|
|
# ----------------------------------------------------------------------
|
|
proxy_cache_path /var/cache/nginx/verbocloud_session_cache levels=1:2 keys_zone=verbocloud_session_cache:10m inactive=60m max_size=100m;
|
|
proxy_cache_path /var/cache/nginx/verbocloud_foldertree_cache levels=1:2 keys_zone=verbocloud_foldertree_cache:10m inactive=1m max_size=100m;
|
|
|
|
# ----------------------------------------------------------------------
|
|
# Declaração dos Backends
|
|
# ----------------------------------------------------------------------
|
|
|
|
# Backend 1: O contêiner do Nextcloud AIO no Windows Server
|
|
upstream nextcloud_aio_backend {
|
|
server 172.16.253.13:11580;
|
|
}
|
|
|
|
# Backend 2: O Office Online Server (nativo no Windows Server)
|
|
upstream office_online_backend {
|
|
# Assumindo que o OOS está na porta 80 (HTTP)
|
|
server 172.16.253.13:80;
|
|
}
|
|
|
|
# ----------------------------------------------------------------------
|
|
# Servidor HTTP (Porta 80)
|
|
# - Redireciona para HTTPS
|
|
# - Responde aos desafios do Let's Encrypt (Certbot)
|
|
# ----------------------------------------------------------------------
|
|
server {
|
|
listen 80;
|
|
listen [::]:80;
|
|
|
|
server_name verbocloud.itguys.com.br;
|
|
|
|
location /.well-known/acme-challenge/ {
|
|
root /var/www/html; # Ajuste o caminho se necessário
|
|
allow all;
|
|
}
|
|
|
|
# Redirecionamento global para HTTPS
|
|
location / {
|
|
return 301 https://$host$request_uri;
|
|
}
|
|
}
|
|
|
|
# ----------------------------------------------------------------------
|
|
# Servidor HTTPS (Porta 443)
|
|
# - Ponto de terminação SSL
|
|
# - Proxy reverso para AIO e OOS
|
|
# - Headers de segurança
|
|
# ----------------------------------------------------------------------
|
|
server {
|
|
listen 443 ssl http2;
|
|
listen [::]:443 ssl http2;
|
|
|
|
server_name verbocloud.itguys.com.br;
|
|
|
|
# --- Logs Exclusivos (Conforme solicitado) ---
|
|
access_log /var/log/nginx/verbocloud.itguys.com.br.access.log detailed_proxy;
|
|
error_log /var/log/nginx/verbocloud.itguys.com.br.error.log warn;
|
|
# (Descomente o log de bad-bot quando implementar o $is_bad_bot)
|
|
# access_log /var/log/nginx/verbocloud.itguys.com.br.bad-bot.log suspicious_bot if=$is_bad_bot;
|
|
|
|
# --- Configurações de SSL ---
|
|
ssl_certificate /etc/letsencrypt/live/verbocloud.itguys.com.br/fullchain.pem; # managed by Certbot
|
|
ssl_certificate_key /etc/letsencrypt/live/verbocloud.itguys.com.br/privkey.pem; # managed by Certbot
|
|
ssl_trusted_certificate /etc/letsencrypt/live/verbocloud.itguys.com.br/fullchain.pem;
|
|
|
|
# --- Otimizações de TLS (Baseado no SSLLabs e no seu arquivo antigo) ---
|
|
ssl_protocols TLSv1.2 TLSv1.3;
|
|
ssl_ciphers 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384';
|
|
ssl_prefer_server_ciphers on;
|
|
ssl_session_timeout 1d;
|
|
ssl_session_tickets off;
|
|
|
|
# --- OCSP Stapling ---
|
|
ssl_stapling on;
|
|
ssl_stapling_verify on;
|
|
resolver 1.1.1.1 8.8.8.8 valid=300s; # Usando resolvers públicos
|
|
resolver_timeout 5s;
|
|
|
|
# --- Headers de Segurança ---
|
|
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload" always;
|
|
add_header X-Content-Type-Options "nosniff" always;
|
|
#add_header X-Frame-Options "SAMEORIGIN" always;
|
|
#add_header Referrer-Policy "no-referrer" always;
|
|
#add_header X-XSS-Protection "1; mode=block" always;
|
|
|
|
# --- Configurações do Proxy ---
|
|
client_max_body_size 10G;
|
|
|
|
brotli on;
|
|
brotli_comp_level 6;
|
|
brotli_min_length 1024;
|
|
brotli_types application/atom+xml application/javascript application/json application/rss+xml application/vnd.ms-fontobject application/x-font-opentype application/x-font-truetype application/x-font-ttf application/x-javascript application/xhtml+xml application/xml font/eot font/opentype font/otf font/truetype image/svg+xml image/x-icon text/css text/javascript text/plain text/xml;
|
|
gzip on;
|
|
gzip_vary on;
|
|
gzip_proxied any;
|
|
gzip_comp_level 6;
|
|
gzip_min_length 1024;
|
|
gzip_types application/atom+xml application/javascript application/json application/rss+xml application/vnd.ms-fontobject application/x-font-opentype application/x-font-truetype application/x-font-ttf application/x-javascript application/xhtml+xml application/xml font/eot font/opentype font/otf font/truetype image/svg+xml image/x-icon text/css text/javascript text/plain text/xml;
|
|
|
|
# ---------------------------------------------------
|
|
# REGRAS DO OFFICE ONLINE SERVER (OOS)
|
|
# (Estas devem vir ANTES do location / principal)
|
|
# ---------------------------------------------------
|
|
|
|
# Rota de Descoberta (Discovery)
|
|
location = /hosting/discovery {
|
|
proxy_pass http://office_online_backend;
|
|
# ===> ATENÇÃO: Substitua pelo Hostname INTERNO que o OOS espera <===
|
|
proxy_set_header Host "nextcloud001";
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
proxy_set_header Accept-Encoding "";
|
|
sub_filter 'http://nextcloud001' 'https://verbocloud.itguys.com.br';
|
|
sub_filter_once off;
|
|
sub_filter_types text/xml application/xml;
|
|
proxy_ssl_verify off;
|
|
}
|
|
|
|
location ~ ^/(m|x|we|o|p|wv|op|wd|rtc|rtc2|layouts|view|_layouts)/ {
|
|
proxy_pass http://office_online_backend;
|
|
proxy_set_header Host "nextcloud001";
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
proxy_set_header X-Forwarded-Host $host;
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
proxy_set_header Connection "upgrade";
|
|
proxy_set_header Accept-Encoding "";
|
|
sub_filter_types text/css text/javascript application/javascript application/json;
|
|
proxy_ssl_verify off;
|
|
if ($request_method = 'OPTIONS') {
|
|
more_set_headers 'Access-Control-Allow-Origin: "$scheme://$http_host"';
|
|
more_set_headers 'Access-Control-Allow-Methods: GET, POST, OPTIONS, HEAD';
|
|
more_set_headers 'Access-Control-Allow-Headers: Authorization, Content-Type, Accept, Origin, User-Agent, DNT, Cache-Control, X-Mx-ReqToken, Keep-Alive, X-Requested-With, If-Modified-Since, X-UserType';
|
|
more_set_headers 'Access-Control-Allow-Credentials: true' always;
|
|
more_set_headers 'Access-Control-Max-Age: 1728000' always;
|
|
return 204;
|
|
}
|
|
|
|
more_set_headers 'Access-Control-Allow-Origin: "$scheme://$http_host"';
|
|
more_set_headers 'Access-Control-Allow-Credentials: true';
|
|
}
|
|
|
|
#location ~* \.(?:css|js|mjs|svg|gif|png|jpg|jpeg|ico|wasm|woff|woff2|ttf|otf|map)$ {
|
|
# proxy_pass http://nextcloud_backend;
|
|
# proxy_set_header Host $host;
|
|
# proxy_set_header X-Real-IP $remote_addr;
|
|
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
# proxy_set_header X-Forwarded-Proto $scheme;
|
|
# proxy_cache nextcloud_cache;
|
|
# proxy_cache_valid 200 30d;
|
|
# proxy_cache_valid any 1m;
|
|
|
|
# more_set_headers 'Cache-Control: public, max-age=31536000, immutable';
|
|
# more_set_headers 'X-Proxy-Cache: $upstream_cache_status';
|
|
|
|
# expires 1y;
|
|
# proxy_hide_header "Cache-Control";
|
|
# proxy_hide_header "Expires";
|
|
# proxy_hide_header "Pragma";
|
|
# brotli_static on;
|
|
# gzip_static on;
|
|
#}
|
|
|
|
# ---------------------------------------------------
|
|
# REGRAS DO NEXTCLOUD AIO
|
|
# (Um único location / para capturar tudo)
|
|
# ---------------------------------------------------
|
|
|
|
# Redirecionamentos CalDAV/CardDAV
|
|
location = /.well-known/carddav { return 301 /remote.php/dav; }
|
|
location = /.well-known/caldav { return 301 /remote.php/dav; }
|
|
location = /.well-known/webfinger { return 301 /index.php/.well-known/webfinger; }
|
|
location = /.well-known/nodeinfo { return 301 /index.php/.well-known/nodeinfo; }
|
|
|
|
# Regra Principal (Nextcloud AIO)
|
|
location / {
|
|
proxy_pass http://nextcloud_aio_backend;
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
proxy_set_header X-Forwarded-Host $host;
|
|
|
|
# --- Headers de WebSocket e Otimizações AIO ---
|
|
# (Isso garante que /push/, /whiteboard/ e /standalone-signaling/ funcionem)
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
proxy_set_header Connection "upgrade";
|
|
proxy_buffering off;
|
|
proxy_request_buffering off;
|
|
|
|
# Timeouts longos
|
|
proxy_connect_timeout 3600s;
|
|
proxy_send_timeout 3600s;
|
|
proxy_read_timeout 3600s;
|
|
}
|
|
}
|