[Auto-Sync] Atualização das configurações em srvproxy001.itguys.com.br - 2025-11-11 00:02:49
This commit is contained in:
parent
b480221d69
commit
7805475f97
|
|
@ -1,26 +1,35 @@
|
|||
# ==============================================================================
|
||||
# ARQUIVO DE CONFIGURAÇÃO VHOST PARA: cloud.grupopralog.com.br
|
||||
# ==============================================================================
|
||||
# AUTOR: Gemini (Especialista NGINX)
|
||||
# DATA DA REATORAÇÃO: 27/09/2025
|
||||
# AUTOR: ITGuys
|
||||
# ÚLTIMA ATUALIZAÇÃO: 2024-07-29
|
||||
#
|
||||
# --- DESCRIÇÃO ---
|
||||
# Esta configuração foi extensivamente otimizada para performance no Nextcloud,
|
||||
# utilizando regras de micro-cache granulares para diferentes tipos de API e
|
||||
# ativos estáticos. As zonas de cache 'nc_static_cache' e 'nc_api_cache'
|
||||
# são definidas no arquivo nginx.conf principal.
|
||||
# ativos estáticos.
|
||||
#
|
||||
# As zonas de cache (ex: 'nc_static_cache', 'nc_api_cache') e outras diretivas
|
||||
# globais (ex: 'map $http_user_agent $should_block_bot') são definidas no
|
||||
# arquivo principal 'nginx.conf'.
|
||||
# ==============================================================================
|
||||
|
||||
# --- MAPAS ESPECÍFICOS DESTE HOST ---
|
||||
# O mapa $cacheable_session_request identifica URIs que podem se beneficiar de um
|
||||
# cache por sessão de usuário. Usado para acelerar a navegação em pastas e dashboard.
|
||||
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;
|
||||
# A URI de DAV foi removida daqui para ter um tratamento de cache específico
|
||||
# no bloco de WebDAV, que lida com o método PROPFIND.
|
||||
# ~^/remote\.php/dav/files/ 1;
|
||||
default 0;
|
||||
}
|
||||
|
||||
# O mapa $session_cache_zone ativa a zona de cache 'nextcloud_session_cache'
|
||||
# apenas para as URIs marcadas pelo mapa anterior.
|
||||
map $cacheable_session_request $session_cache_zone {
|
||||
1 nextcloud_session_cache;
|
||||
default "";
|
||||
|
|
@ -28,14 +37,17 @@ map $cacheable_session_request $session_cache_zone {
|
|||
|
||||
# --- DEFINIÇÃO DOS UPSTREAMS ---
|
||||
upstream nextcloud_backend {
|
||||
# Servidor onde a aplicação Nextcloud (PHP-FPM) está rodando.
|
||||
server 172.16.253.12;
|
||||
}
|
||||
|
||||
upstream officeonline_backend {
|
||||
# Servidor do Collabora Online / Office Online.
|
||||
server 172.16.253.101;
|
||||
}
|
||||
|
||||
upstream windmill_backend {
|
||||
# Exemplo de upstream para outra aplicação, se necessário.
|
||||
server 172.16.253.103:8000;
|
||||
}
|
||||
|
||||
|
|
@ -48,6 +60,7 @@ server {
|
|||
listen [::]:80;
|
||||
server_name cloud.grupopralog.com.br;
|
||||
|
||||
# Permite a renovação de certificados SSL via Let's Encrypt (Certbot).
|
||||
location /.well-known/acme-challenge/ {
|
||||
root /var/www/html;
|
||||
}
|
||||
|
|
@ -67,7 +80,7 @@ server {
|
|||
server_name cloud.grupopralog.com.br;
|
||||
|
||||
# --- BLOQUEIO DE BOTS E CRAWLERS EXTERNOS ---
|
||||
# A variável $should_block_bot é definida em nginx.conf
|
||||
# A variável $should_block_bot é definida via 'map' em nginx.conf.
|
||||
if ($should_block_bot) {
|
||||
return 444;
|
||||
}
|
||||
|
|
@ -76,6 +89,7 @@ server {
|
|||
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;
|
||||
# Log específico para registrar bots bloqueados ou suspeitos.
|
||||
access_log /var/log/nginx/cloud.grupopralog.com.br.bad-bot.log suspicious_bot if=$is_bad_bot;
|
||||
|
||||
# --- HEADERS DE SEGURANÇA ---
|
||||
|
|
@ -83,6 +97,7 @@ server {
|
|||
add_header X-Content-Type-Options "nosniff" always;
|
||||
add_header X-Frame-Options "SAMEORIGIN" always;
|
||||
add_header Referrer-Policy "no-referrer" always;
|
||||
# Esconde headers que podem vazar informações do backend.
|
||||
proxy_hide_header "X-Content-Type-Options";
|
||||
proxy_hide_header "X-Frame-Options";
|
||||
proxy_hide_header "Feature-Policy";
|
||||
|
|
@ -93,6 +108,7 @@ server {
|
|||
proxy_buffer_size 512k;
|
||||
proxy_buffers 32 256k;
|
||||
proxy_busy_buffers_size 512k;
|
||||
# Timeouts longos para suportar uploads/downloads de arquivos grandes.
|
||||
proxy_connect_timeout 1200s;
|
||||
proxy_send_timeout 1200s;
|
||||
proxy_read_timeout 1200s;
|
||||
|
|
@ -110,6 +126,7 @@ server {
|
|||
ssl_session_tickets off;
|
||||
ssl_stapling on;
|
||||
ssl_stapling_verify on;
|
||||
# Resolver para OCSP Stapling.
|
||||
ssl_trusted_certificate /etc/letsencrypt/live/cloud.grupopralog.com.br/fullchain.pem;
|
||||
resolver 127.0.0.1 valid=300s;
|
||||
resolver_timeout 5s;
|
||||
|
|
@ -127,6 +144,7 @@ server {
|
|||
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;
|
||||
|
||||
# --- REDIRECIONAMENTOS PADRÃO (WELL-KNOWN) ---
|
||||
# Facilita a configuração automática de clientes CalDAV e CardDAV.
|
||||
location = /.well-known/carddav { return 301 /remote.php/dav; }
|
||||
location = /.well-known/caldav { return 301 /remote.php/dav; }
|
||||
|
||||
|
|
@ -136,7 +154,8 @@ server {
|
|||
# ==========================================================================
|
||||
|
||||
# --- Cache de Avatares (1 hora) ---
|
||||
location ~ ^/index\.php/avatar/ {
|
||||
# Avatares são cacheados por 1 hora. A chave de cache inclui apenas a URI.
|
||||
location ~ ^/index\.php/avatar/ { # Ex: /index.php/avatar/admin/128
|
||||
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_http_version 1.1; proxy_set_header Connection "";
|
||||
proxy_buffering on;
|
||||
|
|
@ -145,13 +164,14 @@ server {
|
|||
proxy_cache_valid 200 1h;
|
||||
proxy_cache_lock on;
|
||||
proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504;
|
||||
proxy_ignore_headers "Cache-Control" "Expires";
|
||||
proxy_hide_header "Cache-Control"; proxy_hide_header "Expires"; proxy_hide_header "Pragma";
|
||||
add_header Cache-Control "public, max-age=3600";
|
||||
more_set_headers 'X-Avatar-Cache: $upstream_cache_status';
|
||||
}
|
||||
|
||||
# --- Cache de Tema, Ícones de Mime (12 horas) ---
|
||||
location ~ ^/index\.php/(apps/theming/(theme/|image/|manifest/|favicon/|icon/|img/)|core/mimeicon) {
|
||||
# Ativos de tema e ícones de tipo de arquivo mudam raramente.
|
||||
location ~ ^/index\.php/(apps/theming/(theme/|image/|manifest/|favicon/|icon/|img/)|core/mimeicon) { # Ex: /index.php/core/mimeicon/folder
|
||||
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_http_version 1.1; proxy_set_header Connection "";
|
||||
proxy_buffering on;
|
||||
|
|
@ -160,13 +180,14 @@ server {
|
|||
proxy_cache_valid 200 12h;
|
||||
proxy_cache_lock on;
|
||||
proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504;
|
||||
proxy_ignore_headers "Cache-Control" "Expires" ;
|
||||
proxy_hide_header "Cache-Control"; proxy_hide_header "Expires"; proxy_hide_header "Pragma";
|
||||
add_header Cache-Control "public, max-age=43200";
|
||||
more_set_headers 'X-Theme-Asset-Cache: $upstream_cache_status';
|
||||
}
|
||||
|
||||
# --- Cache de Previews do Core (15 minutos) ---
|
||||
location ~ ^/index\.php/core/preview {
|
||||
# Previews de arquivos são cacheadas por usuário para evitar acesso cruzado.
|
||||
location ~ ^/index\.php/core/preview { # Ex: /index.php/core/preview?fileId=123...
|
||||
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_http_version 1.1; proxy_set_header Connection "";
|
||||
proxy_buffering on;
|
||||
|
|
@ -177,13 +198,14 @@ server {
|
|||
proxy_cache_valid 200 15m;
|
||||
proxy_cache_lock on;
|
||||
proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504;
|
||||
proxy_ignore_headers "Cache-Control" "Expires" "Pragma";
|
||||
proxy_hide_header "Cache-Control"; proxy_hide_header "Expires"; proxy_hide_header "Pragma";
|
||||
add_header Cache-Control "public, max-age=900";
|
||||
more_set_headers 'X-Core-Preview-Cache: $upstream_cache_status';
|
||||
}
|
||||
|
||||
# --- Cache de Previews da Lixeira e Versões (5 minutos) ---
|
||||
location ~ ^/index\.php/apps/(files_trashbin|files_versions)/preview {
|
||||
# Previews de arquivos na lixeira ou de versões antigas.
|
||||
location ~ ^/index\.php/apps/(files_trashbin|files_versions)/preview { # Ex: /index.php/apps/files_trashbin/preview?file=...
|
||||
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_http_version 1.1; proxy_set_header Connection "";
|
||||
proxy_buffering on;
|
||||
|
|
@ -194,13 +216,14 @@ server {
|
|||
proxy_cache_valid 200 5m;
|
||||
proxy_cache_lock on;
|
||||
proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504;
|
||||
proxy_ignore_headers "Cache-Control" "Expires" "Pragma";
|
||||
proxy_hide_header "Cache-Control"; proxy_hide_header "Expires"; proxy_hide_header "Pragma";
|
||||
add_header Cache-Control "public, max-age=300";
|
||||
more_set_headers 'X-File-Preview-Cache: $upstream_cache_status';
|
||||
}
|
||||
|
||||
# --- Cache de Previews de Links Públicos (5 minutos) ---
|
||||
location ~ ^/(index\.php/s/[^/]+/preview|index\.php/apps/files_sharing/publicpreview/) {
|
||||
# Previews em páginas de compartilhamento público não dependem de sessão.
|
||||
location ~ ^/(index\.php/s/[^/]+/preview|index\.php/apps/files_sharing/publicpreview/) { # Ex: /index.php/s/shareToken/preview?file=...
|
||||
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_http_version 1.1; proxy_set_header Connection "";
|
||||
proxy_buffering on;
|
||||
|
|
@ -211,19 +234,21 @@ server {
|
|||
proxy_cache_valid 200 5m;
|
||||
proxy_cache_lock on;
|
||||
proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504;
|
||||
proxy_ignore_headers "Cache-Control" "Expires" ;
|
||||
proxy_hide_header "Cache-Control"; proxy_hide_header "Expires"; proxy_hide_header "Pragma";
|
||||
add_header Cache-Control "public, max-age=300";
|
||||
more_set_headers 'X-Public-Preview-Cache: $upstream_cache_status';
|
||||
}
|
||||
|
||||
# --- Cache para ativos estáticos genéricos (.js, .css, etc) ---
|
||||
# Bloco genérico para todos os outros ativos estáticos.
|
||||
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;
|
||||
|
||||
# (CORREÇÃO) Se o backend retornar uma página HTML para um ativo estático,
|
||||
# é porque o arquivo não foi encontrado (erro 404).
|
||||
# Em vez de enviar o HTML (o que causa o erro de MIME type), retornamos um 404 limpo.
|
||||
# CORREÇÃO DE MIME-TYPE: Se o backend retornar 'text/html' para um recurso
|
||||
# estático (como .js ou .css), significa que o recurso não foi encontrado
|
||||
# e o Nextcloud está retornando uma página de erro. Isso causa um erro de
|
||||
# MIME-type no navegador. Aqui, interceptamos isso e retornamos um 404 limpo.
|
||||
if ($upstream_http_content_type = 'text/html') {
|
||||
return 404;
|
||||
}
|
||||
|
|
@ -235,6 +260,7 @@ server {
|
|||
proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504;
|
||||
more_set_headers 'Cache-Control: public, max-age=43200';
|
||||
more_set_headers 'X-Proxy-Cache: $upstream_cache_status';
|
||||
# Esconde headers de cache do backend para que o Nginx tenha controle total.
|
||||
proxy_hide_header "Cache-Control"; proxy_hide_header "Expires"; proxy_hide_header "Pragma";
|
||||
brotli_static on; gzip_static on;
|
||||
}
|
||||
|
|
@ -245,7 +271,8 @@ server {
|
|||
# ==========================================================================
|
||||
|
||||
# --- Cache de Autocomplete (30 segundos) ---
|
||||
location = /ocs/v2.php/core/autocomplete/get {
|
||||
# Usado na busca de usuários, tags, etc. Cache curto para manter os dados atualizados.
|
||||
location = /ocs/v2.php/core/autocomplete/get { # Ex: /ocs/v2.php/core/autocomplete/get?search=...
|
||||
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_http_version 1.1; proxy_set_header Connection "";
|
||||
proxy_buffering on;
|
||||
|
|
@ -256,13 +283,14 @@ server {
|
|||
proxy_cache_valid 200 30s;
|
||||
proxy_cache_lock on;
|
||||
proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504;
|
||||
proxy_ignore_headers "Cache-Control" "Expires";
|
||||
proxy_hide_header "Cache-Control"; proxy_hide_header "Expires"; proxy_hide_header "Pragma";
|
||||
add_header Cache-Control "public, max-age=30";
|
||||
more_set_headers 'X-Autocomplete-Cache: $upstream_cache_status';
|
||||
}
|
||||
|
||||
# --- Cache de Busca de Usuários para Partilha (30 segundos) ---
|
||||
location = /ocs/v2.php/apps/files_sharing/api/v1/sharees {
|
||||
# API específica para buscar usuários/grupos na janela de compartilhamento.
|
||||
location = /ocs/v2.php/apps/files_sharing/api/v1/sharees { # Ex: /ocs/v2.php/apps/files_sharing/api/v1/sharees?search=...
|
||||
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_http_version 1.1; proxy_set_header Connection "";
|
||||
proxy_buffering on;
|
||||
|
|
@ -273,13 +301,14 @@ server {
|
|||
proxy_cache_valid 200 30s;
|
||||
proxy_cache_lock on;
|
||||
proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504;
|
||||
proxy_ignore_headers "Cache-Control" "Expires";
|
||||
proxy_hide_header "Cache-Control"; proxy_hide_header "Expires"; proxy_hide_header "Pragma";
|
||||
add_header Cache-Control "public, max-age=30";
|
||||
more_set_headers 'X-Sharee-Search-Cache: $upstream_cache_status';
|
||||
}
|
||||
|
||||
# --- Cache para APIs do Core, Navegação, Status, etc (5-10 segundos) ---
|
||||
location ~ ^/ocs/v2\.php/(settings/api/declarative/forms|core/navigation/|cloud/capabilities|hovercard/v1/|profile/) {
|
||||
# --- Cache para APIs do Core, Navegação, Status, etc (5 minutos) ---
|
||||
# Agrupa várias APIs de UI que não mudam com frequência.
|
||||
location ~ ^/ocs/v2\.php/(settings/api/declarative/forms|core/navigation/|cloud/capabilities|hovercard/v1/|profile/) { # Ex: /ocs/v2.php/cloud/capabilities
|
||||
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_http_version 1.1; proxy_set_header Connection "";
|
||||
proxy_buffering on;
|
||||
|
|
@ -290,12 +319,14 @@ server {
|
|||
proxy_cache_valid 200 5m;
|
||||
proxy_cache_lock on;
|
||||
proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504;
|
||||
proxy_ignore_headers "Cache-Control" "Expires" "Pragma";
|
||||
proxy_hide_header "Cache-Control"; proxy_hide_header "Expires"; proxy_hide_header "Pragma";
|
||||
add_header Cache-Control "public, max-age=300";
|
||||
more_set_headers 'X-Core-API-Cache: $upstream_cache_status';
|
||||
}
|
||||
|
||||
location ~ ^/ocs/v2\.php/apps/user_status/api/v1/(statuses|user_status) {
|
||||
# --- Cache de Status de Usuário (10 segundos) ---
|
||||
# O status (online, ausente) muda com frequência. Cache muito curto.
|
||||
location ~ ^/ocs/v2\.php/apps/user_status/api/v1/(statuses|user_status) { # Ex: /ocs/v2.php/apps/user_status/api/v1/user_status
|
||||
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_http_version 1.1; proxy_set_header Connection "";
|
||||
proxy_buffering on;
|
||||
|
|
@ -306,13 +337,14 @@ server {
|
|||
proxy_cache_valid 200 10s;
|
||||
proxy_cache_lock on;
|
||||
proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504;
|
||||
proxy_ignore_headers "Cache-Control" "Expires";
|
||||
proxy_hide_header "Cache-Control"; proxy_hide_header "Expires"; proxy_hide_header "Pragma";
|
||||
add_header Cache-Control "public, max-age=10";
|
||||
more_set_headers 'X-User-Status-Cache: $upstream_cache_status';
|
||||
}
|
||||
|
||||
# --- Cache para APIs de Configuração e Listas (longa duração) ---
|
||||
location = /ocs/v2.php/apps/user_status/api/v1/predefined_statuses {
|
||||
# Lista de status predefinidos. Muda muito raramente.
|
||||
location = /ocs/v2.php/apps/user_status/api/v1/predefined_statuses { # Ex: /ocs/v2.php/apps/user_status/api/v1/predefined_statuses
|
||||
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_http_version 1.1; proxy_set_header Connection "";
|
||||
proxy_buffering on;
|
||||
|
|
@ -323,12 +355,13 @@ server {
|
|||
proxy_cache_valid 200 1h;
|
||||
proxy_cache_lock on;
|
||||
proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504;
|
||||
proxy_ignore_headers "Cache-Control" "Expires" "Pragma";
|
||||
proxy_hide_header "Cache-Control"; proxy_hide_header "Expires"; proxy_hide_header "Pragma";
|
||||
add_header Cache-Control "public, max-age=3600";
|
||||
more_set_headers 'X-Predefined-Status-Cache: $upstream_cache_status';
|
||||
}
|
||||
|
||||
location ~ ^/ocs/v2\.php/apps/user_ldap/api/v1/config/ {
|
||||
# Configurações da aplicação LDAP.
|
||||
location ~ ^/ocs/v2\.php/apps/user_ldap/api/v1/config/ { # Ex: /ocs/v2.php/apps/user_ldap/api/v1/config/s01
|
||||
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_http_version 1.1; proxy_set_header Connection "";
|
||||
proxy_buffering on;
|
||||
|
|
@ -339,12 +372,13 @@ server {
|
|||
proxy_cache_valid 200 15m;
|
||||
proxy_cache_lock on;
|
||||
proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504;
|
||||
proxy_ignore_headers "Cache-Control" "Expires";
|
||||
proxy_hide_header "Cache-control"; proxy_hide_header "Expires"; proxy_hide_header "Pragma";
|
||||
add_header Cache-Control "public, max-age=900";
|
||||
more_set_headers 'X-LDAP-Config-Cache: $upstream_cache_status';
|
||||
}
|
||||
|
||||
location ~ ^/index\.php/apps/groupfolders/(delegation|folders) {
|
||||
# Lista de Pastas de Grupo e suas permissões.
|
||||
location ~ ^/index\.php/apps/groupfolders/(delegation|folders) { # Ex: /index.php/apps/groupfolders/folders
|
||||
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_http_version 1.1; proxy_set_header Connection "";
|
||||
proxy_buffering on;
|
||||
|
|
@ -355,12 +389,13 @@ server {
|
|||
proxy_cache_valid 200 5m;
|
||||
proxy_cache_lock on;
|
||||
proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504;
|
||||
proxy_ignore_headers "Cache-Control" "Expires;
|
||||
proxy_hide_header "Cache-Control"; proxy_hide_header "Expires"; proxy_hide_header "Pragma";
|
||||
add_header Cache-Control "public, max-age=300";
|
||||
more_set_headers 'X-GroupFolders-Cache: $upstream_cache_status';
|
||||
}
|
||||
|
||||
location ~ ^/ocs/v2\.php/apps/updatenotification/api/ {
|
||||
# Verificação de atualizações do Nextcloud. Não precisa ser feita a toda hora.
|
||||
location ~ ^/ocs/v2\.php/apps/updatenotification/api/ { # Ex: /ocs/v2.php/apps/updatenotification/api/v1/applist
|
||||
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_http_version 1.1; proxy_set_header Connection "";
|
||||
proxy_buffering on;
|
||||
|
|
@ -371,12 +406,14 @@ server {
|
|||
proxy_cache_valid 200 1h;
|
||||
proxy_cache_lock on;
|
||||
proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504;
|
||||
proxy_ignore_headers "Cache-Control" "Expires" "Pragma";
|
||||
proxy_hide_header "Cache-Control"; proxy_hide_header "Expires"; proxy_hide_header "Pragma";
|
||||
add_header Cache-Control "public, max-age=3600";
|
||||
more_set_headers 'X-Update-Cache: $upstream_cache_status';
|
||||
}
|
||||
|
||||
location ~ ^/(ocs/v[12].php/cloud/users|ocs/v[12].php/privatedata/get|ocs/v2.php/apps/notifications/api/v2/notifications(/.*)?|ocs/v[12].php/cloud/apps|ocs/v[12].php/cloud/user|ocs/v[12].php/privatedata/get/userinfo) {
|
||||
# --- Micro-cache para APIs de alta frequência ---
|
||||
# APIs de notificação, dados do usuário, etc. são chamadas constantemente. Um cache de 5s reduz a carga sem mostrar dados obsoletos.
|
||||
location ~ ^/(ocs/v[12].php/cloud/users|ocs/v[12].php/privatedata/get|ocs/v2.php/apps/notifications/api/v2/notifications(/.*)?|ocs/v[12].php/cloud/apps|ocs/v[12].php/cloud/user|ocs/v[12].php/privatedata/get/userinfo) { # Ex: /ocs/v2.php/apps/notifications/api/v2/notifications
|
||||
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_http_version 1.1; proxy_set_header Connection "";
|
||||
proxy_buffering on;
|
||||
|
|
@ -391,20 +428,28 @@ server {
|
|||
# GRUPO 3: TRATAMENTOS ESPECIAIS (OFFICE, WEBDAV, ETC)
|
||||
# ==========================================================================
|
||||
|
||||
# --- Rota de Descoberta do Office Online ---
|
||||
location = /hosting/discovery {
|
||||
proxy_pass https://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 "";
|
||||
# O backend do Office pode usar um certificado auto-assinado.
|
||||
proxy_ssl_verify off;
|
||||
}
|
||||
|
||||
# --- Rotas do Office Online (WOPI) ---
|
||||
# Redireciona todo o tráfego relacionado à edição de documentos para o backend do Office.
|
||||
location ~ ^/(m|x|we|o|p|wv|op|wd|rtc|rtc2|layouts|view|_layouts)/ {
|
||||
proxy_pass https://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;
|
||||
# Necessário para WebSockets.
|
||||
proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header Accept-Encoding "";
|
||||
# Desativa o buffering para comunicação em tempo real.
|
||||
proxy_buffering off; proxy_request_buffering off;
|
||||
proxy_connect_timeout 1200s; proxy_send_timeout 1200s; proxy_read_timeout 1200s;
|
||||
# Substitui a URL do backend pela URL pública para que os recursos sejam carregados corretamente no navegador.
|
||||
sub_filter 'srvoffice001.itguys.com.br' 'cloud.grupopralog.com.br';
|
||||
sub_filter_once off; sub_filter_types text/css text/javascript application/javascript application/json;
|
||||
# Bloco para lidar com requisições pre-flight (CORS).
|
||||
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';
|
||||
|
|
@ -417,21 +462,30 @@ server {
|
|||
more_set_headers 'Access-Control-Allow-Credentials: true';
|
||||
}
|
||||
|
||||
# --- Rota de WebDAV e Uploads de Formulários ---
|
||||
# Trata as requisições WebDAV (sincronização de clientes desktop/mobile) e uploads de arquivos do app Forms.
|
||||
location ~ ^/(remote\.php/(webdav|dav)|ocs/v[12]\.php/apps/forms/api/.*/submissions/files/.*) {
|
||||
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_http_version 1.1; proxy_set_header Connection "";
|
||||
# Desativa o buffering para PUT/GET de arquivos para não consumir memória desnecessariamente.
|
||||
proxy_buffering off; proxy_request_buffering off;
|
||||
|
||||
# Otimização para PROPFIND: requisições que listam arquivos e pastas.
|
||||
# Elas podem ser cacheadas por um curto período para reduzir a carga no backend
|
||||
# durante a sincronização inicial de um cliente.
|
||||
if ($request_method = PROPFIND) {
|
||||
proxy_buffering on; proxy_request_buffering on;
|
||||
proxy_cache nc_api_cache; # Usando o cache de API para listagens DAV
|
||||
# NOTA: Esta seção foi desativada no plano de ação (nextcloud_sync_fix_plan.md)
|
||||
# para diagnosticar problemas de lock. Manter comentado até a resolução.
|
||||
# proxy_cache nc_api_cache;
|
||||
proxy_cache_methods PROPFIND;
|
||||
proxy_cache_key "$host$request_uri|$cookie_nc_session_id";
|
||||
proxy_cache_valid 200 207 10s;
|
||||
proxy_cache_valid 200 207 10s; # 207 é o status de sucesso para Multi-Status (PROPFIND)
|
||||
proxy_cache_lock on;
|
||||
proxy_cache_use_stale error timeout http_500 http_502 http_503 http_504;
|
||||
more_set_headers 'X-DAV-Cache: $upstream_cache_status';
|
||||
proxy_ignore_headers "Cache-Control" "Expires" "Pragma";
|
||||
proxy_hide_header "Cache-Control"; proxy_hide_header "Expires"; proxy_hide_header "Pragma";
|
||||
add_header Cache-Control "public, max-age=10";
|
||||
}
|
||||
proxy_connect_timeout 60s; proxy_read_timeout 1200s; proxy_send_timeout 1200s;
|
||||
|
|
@ -441,6 +495,8 @@ server {
|
|||
# GRUPO 4: BLOCO CATCH-ALL FINAL
|
||||
# ==========================================================================
|
||||
|
||||
# Este bloco captura todas as outras requisições que não foram tratadas
|
||||
# pelos blocos 'location' mais específicos acima.
|
||||
location / {
|
||||
proxy_pass http://nextcloud_backend;
|
||||
proxy_set_header Host $host;
|
||||
|
|
@ -448,6 +504,7 @@ server {
|
|||
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;
|
||||
# Ativa o cache de sessão (definido nos mapas no topo do arquivo).
|
||||
proxy_cache $session_cache_zone;
|
||||
proxy_cache_key "$scheme$request_method$host$request_uri$is_args$args$cookie_nc_session_id";
|
||||
proxy_cache_valid 200 5m;
|
||||
|
|
@ -462,6 +519,7 @@ server {
|
|||
proxy_read_timeout 1200s;
|
||||
proxy_send_timeout 1200s;
|
||||
proxy_buffering on;
|
||||
# Desativa o buffer de requisição para que uploads maiores comecem a ser enviados ao backend imediatamente.
|
||||
proxy_request_buffering off;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue