307 lines
11 KiB
Plaintext
307 lines
11 KiB
Plaintext
#
|
|
# Configuração de TESTE: cloud.grupopralog.com.br
|
|
# Atualizado em: 2025-11-11 @ 01:45 (Horário de Brasília)
|
|
# Contexto: Correção do 502 (Bad Gateway) no Office Online.
|
|
# - Adicionado "proxy_ssl_verify off;" ao location WOPI
|
|
# para permitir certificado autoassinado do backend.
|
|
#
|
|
|
|
map $request_uri $cache_asset {
|
|
~*\.(css|js|mjs|svg|gif|png|jpg|jpeg|ico|wasm|woff|woff2|ttf|otf)$ 1y;
|
|
default off;
|
|
}
|
|
|
|
map $request_uri $cacheable_session_request {
|
|
~^/apps/files/$ 1;
|
|
~^/apps/files/files$ 1;
|
|
~^/apps/files/\?dir= 1;
|
|
~^/apps/dashboard/$ 1;
|
|
~^/remote\.php/dav/files/ 1;
|
|
default 0;
|
|
}
|
|
|
|
map $cacheable_session_request $session_cache_zone {
|
|
1 nextcloud_session_cache;
|
|
default "";
|
|
}
|
|
|
|
upstream nextcloud_backend {
|
|
server 172.16.253.12;
|
|
}
|
|
|
|
upstream officeonline_backend {
|
|
server 172.16.253.101;
|
|
}
|
|
|
|
server {
|
|
listen 80;
|
|
listen [::]:80;
|
|
server_name cloud.grupopralog.com.br;
|
|
|
|
location /.well-known/acme-challenge/ {
|
|
root /var/www/html;
|
|
}
|
|
|
|
location / {
|
|
return 301 https://$host$request_uri;
|
|
}
|
|
}
|
|
|
|
server {
|
|
listen 443 ssl http2;
|
|
listen [::]:443 ssl http2;
|
|
server_name cloud.grupopralog.com.br;
|
|
|
|
client_max_body_size 10G;
|
|
access_log /var/log/nginx/cloud.grupopralog.com.br.access.log detailed_proxy;
|
|
error_log /var/log/nginx/cloud.grupopralog.com.br.error.log warn;
|
|
access_log /var/log/nginx/cloud.grupopralog.com.br.bad-bot.log suspicious_bot if=$is_bad_bot;
|
|
|
|
# Segurança Headers
|
|
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;
|
|
|
|
# Buffers (Globais para este Server)
|
|
client_body_buffer_size 128M;
|
|
proxy_buffer_size 512k;
|
|
proxy_buffers 32 256k;
|
|
proxy_busy_buffers_size 512k;
|
|
proxy_connect_timeout 1200s;
|
|
proxy_send_timeout 1200s;
|
|
proxy_read_timeout 1200s;
|
|
proxy_temp_file_write_size 512k;
|
|
|
|
# Ocultar headers do backend
|
|
proxy_hide_header X-Content-Type-Options;
|
|
proxy_hide_header X-Frame-Options;
|
|
proxy_hide_header Feature-Policy;
|
|
proxy_hide_header Content-Security-Policy;
|
|
|
|
# SSL
|
|
ssl_certificate /etc/letsencrypt/live/cloud.grupopralog.com.br/fullchain.pem;
|
|
ssl_certificate_key /etc/letsencrypt/live/cloud.grupopralog.com.br/privkey.pem;
|
|
ssl_protocols TLSv1.3 TLSv1.2;
|
|
ssl_ciphers 'TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY_1305_SHA2ANET-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305';
|
|
ssl_prefer_server_ciphers on;
|
|
ssl_ecdh_curve X25519:secp256r1:secp384r1;
|
|
ssl_dhparam /etc/nginx/dhparam.pem;
|
|
ssl_session_timeout 1d;
|
|
ssl_session_tickets off;
|
|
|
|
# SSL Stapling
|
|
ssl_stapling on;
|
|
ssl_stapling_verify on;
|
|
ssl_trusted_certificate /etc/letsencrypt/live/cloud.grupopralog.com.br/fullchain.pem;
|
|
resolver 127.0.0.1 valid=300s;
|
|
resolver_timeout 5s;
|
|
|
|
# Compressão
|
|
brotli on;
|
|
brotli_comp_level 6;
|
|
brotli_min_length 1024;
|
|
brotli_types
|
|
application/atom+xml
|
|
application/javascript
|
|
application/json
|
|
application/ld+json
|
|
application/manifest+json
|
|
application/rss+xml
|
|
application/vnd.ms-fontobject
|
|
application/x-font-opentype
|
|
application/x-font-truetype
|
|
application/x-javascript
|
|
application/xhtml+xml
|
|
application/xml
|
|
font/eot
|
|
font/opentype
|
|
font/otf
|
|
font/truetype
|
|
font/woff
|
|
font/woff2
|
|
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/ld+json
|
|
application/manifest+json
|
|
application/rss+xml
|
|
application/vnd.ms-fontobject
|
|
application/x-font-opentype
|
|
application/x-font-truetype
|
|
application/x-javascript
|
|
application/xhtml+xml
|
|
application/xml
|
|
font/eot
|
|
font/opentype
|
|
font/otf
|
|
font/truetype
|
|
font/woff
|
|
font/woff2
|
|
image/svg+xml
|
|
image/x-icon
|
|
text/css
|
|
text/javascript
|
|
text/plain
|
|
text/xml;
|
|
|
|
# CalDAV / CardDAV
|
|
location = /.well-known/carddav { return 301 /remote.php/dav; }
|
|
location = /.well-known/caldav { return 301 /remote.php/dav; }
|
|
|
|
# Office Online (Discovery)
|
|
location = /hosting/discovery {
|
|
proxy_pass http://officeonline_backend;
|
|
proxy_set_header Host "srvoffice001.itguys.com.br";
|
|
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 "";
|
|
proxy_ssl_verify off;
|
|
#Alteraçoes 12/11/2025
|
|
sub_filter 'srvoffice001.itguys.com.br' 'cloud.grupopralog.com.br';
|
|
sub_filter 'https://srvoffice001.itguys.com.br' 'https://cloud.grupopralog.com.br';
|
|
sub_filter 'https:\/\/srvoffice001.itguys.com.br' 'https:\/\/cloud.grupopralog.com.br';
|
|
sub_filter 'http://srvoffice001.itguys.com.br' 'https://cloud.grupopralog.com.br';
|
|
sub_filter_once off;
|
|
sub_filter_types text/xml;
|
|
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';
|
|
#Fim alteracao
|
|
}
|
|
|
|
# Office Online (WOPI)
|
|
#12/11/2025
|
|
location ~ ^/(rtc|rtc2)/ {
|
|
proxy_pass http://officeonline_backend;
|
|
|
|
# Headers de Proxy
|
|
proxy_set_header Host "srvoffice001.itguys.com.br";
|
|
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_set_header Accept-Encoding "";
|
|
|
|
# Configuração ESSENCIAL para WebSockets
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
proxy_set_header Connection "upgrade";
|
|
|
|
# Configuração ESSENCIAL para streaming (Interface estranha)
|
|
proxy_buffering off;
|
|
proxy_request_buffering off;
|
|
|
|
# Timeouts longos
|
|
proxy_connect_timeout 1200s;
|
|
proxy_send_timeout 1200s;
|
|
proxy_read_timeout 1200s;
|
|
}
|
|
#Fim 12/11/2025
|
|
|
|
location ~ ^/(m|x|we|o|p|wv|op|wd|layouts|view|_layouts|app_scripts|Resources)/ {
|
|
gunzip on;
|
|
expires -1;
|
|
etag off;
|
|
proxy_no_cache 1;
|
|
proxy_cache_bypass 1;
|
|
proxy_pass http://officeonline_backend;
|
|
proxy_set_header Host "srvoffice001.itguys.com.br";
|
|
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_set_header Accept-Encoding "";
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
proxy_set_header Connection "upgrade";
|
|
proxy_connect_timeout 1200s;
|
|
proxy_send_timeout 1200s;
|
|
proxy_read_timeout 1200s;
|
|
sub_filter 'srvoffice001.itguys.com.br' 'cloud.grupopralog.com.br';
|
|
sub_filter 'https://srvoffice001.itguys.com.br' 'https://cloud.grupopralog.com.br';
|
|
sub_filter 'http://srvoffice001.itguys.com.br' 'https://cloud.grupopralog.com.br';
|
|
sub_filter 'https:\/\/srvoffice001.itguys.com.br' 'https:\/\/cloud.grupopralog.com.br';
|
|
sub_filter 'http:\/\/srvoffice001.itguys.com.br' 'https:\/\/cloud.grupopralog.com.br';
|
|
sub_filter_once off;
|
|
sub_filter_types text/html text/css text/javascript application/javascript application/json application/x-javascript application/xml;
|
|
|
|
# --- CORRIGIDO AQUI (Adicionado para corrigir o 502) ---
|
|
#proxy_ssl_verify off;
|
|
|
|
more_clear_headers 'X-Content-Type-Options';
|
|
|
|
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';
|
|
}
|
|
|
|
# Bloco de Cache para Ativos Estáticos
|
|
# Otimizado para máxima performance em arquivos imutáveis (versionados).
|
|
location ~* \.(?:css|js|mjs|svg|gif|png|jpg|jpeg|ico|wasm|woff|woff2|ttf|otf)$ {
|
|
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_set_header X-Forwarded-Host $host;
|
|
|
|
# Buffering otimizado para proxy reverso.
|
|
proxy_buffering on;
|
|
|
|
# Cache Headers - Define o cache máximo no navegador (1 ano).
|
|
expires 1y;
|
|
add_header Cache-Control "public, immutable";
|
|
|
|
# Mantém o log de acesso, mas desativa o log para 'arquivo não encontrado'.
|
|
log_not_found off;
|
|
}
|
|
|
|
# Location Padrão (Catch-all) - SEM CACHE
|
|
location / {
|
|
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_set_header X-Forwarded-Host $host;
|
|
proxy_set_header Authorization $http_authorization;
|
|
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Connection "";
|
|
proxy_connect_timeout 60s;
|
|
proxy_read_timeout 1200s;
|
|
proxy_send_timeout 1200s;
|
|
proxy_buffering on;
|
|
proxy_request_buffering off;
|
|
}
|
|
}
|