diff --git a/.gemini/TODO.md b/.gemini/TODO.md index 5b022ef..a54a09b 100644 --- a/.gemini/TODO.md +++ b/.gemini/TODO.md @@ -17,3 +17,24 @@ - **Status:** ✅ Concluído. - **Solução Implementada:** Script `./scripts/reload.sh` que executa `nginx -t` e `nginx -s reload` (Reload Suave/Process-Level Blue-Green). - **Como usar:** Execute `./scripts/reload.sh` após alterar qualquer `.conf`. + +## 4. Conexão Direta na Interface do Host +**Objetivo:** Configurar o proxy para rotear tráfego tanto internamente (entre containers Docker) quanto externamente (para serviços fora do Docker). +- **Status:** 🧪 Implementado - Aguardando Teste no Host +- **Solução Implementada:** + - Adicionado `host.docker.internal:host-gateway` no `docker-compose.yml` para ambos containers + - Criado `snippets/docker_resolver.conf` para resolução DNS dinâmica de containers + - Criado `conf.d/test-connectivity.conf` (temporário) com endpoints de teste + - Atualizado diagrama de arquitetura no `README.md` +- **Testes Necessários (no host de deploy):** + ```bash + # Rebuild e restart + docker compose build --no-cache nginx-proxy + docker compose down && docker compose up -d + + # Testar conectividade + docker compose exec nginx-proxy ping -c 2 10.10.253.254 + docker compose exec nginx-proxy ping -c 2 10.10.253.128 + ``` +- **Após Validação:** Deletar `conf.d/test-connectivity.conf` e marcar como ✅ Concluído. + diff --git a/README.md b/README.md index b64cb49..7402367 100644 --- a/README.md +++ b/README.md @@ -144,20 +144,95 @@ O sistema gerencia isso automaticamente, mas você pode intervir manualmente se ## 🏗️ Visão Geral da Stack ```mermaid -graph LR - Internet((Internet)) --> WAF[Container ModSecurity] - WAF -- Tráfego Limpo --> Proxy[Container NGINX Proxy] - Proxy --> Backend1[App 1] - Proxy --> Backend2[App 2] +graph TD + subgraph Internet + Client[Cliente Externo] + end + + subgraph Host["Host Docker (Portainer)"] + subgraph PathfinderStack["Stack: Pathfinder-Proxy
Rede: 172.112.0.0/16"] + WAF["ModSecurity WAF
172.112.0.3
:80, :443"] + NGINX["nginx-proxy
172.112.0.2
:8080 interno"] + F2B["fail2ban
network: host"] + end + + subgraph HostNetwork["Rede Física do Host"] + HostIP["host.docker.internal
(gateway)"] + end + + subgraph OtherStacks["Outras Stacks Docker"] + Container1["Container A
172.111.0.x"] + Container2["Container B
172.113.0.x"] + end + end + + subgraph ExternalServers["Servidores Externos"] + Server254["10.10.253.254"] + Server128["10.10.253.128
Gitea"] + end + + Client -->|":80/:443"| WAF + WAF -->|"proxy_pass :8080"| NGINX + F2B -.->|"lê logs"| WAF + F2B -.->|"lê logs"| NGINX - Logs[Logs Compartilhados] - WAF -.-> Logs - Proxy -.-> Logs - - F2B[Container Fail2ban] - F2B -- Lê --> Logs - F2B -- Bane IP --> WAF + NGINX -->|"extra_hosts
host-gateway"| HostIP + NGINX -.->|"bridge network"| Container1 + NGINX -.->|"bridge network"| Container2 + HostIP -->|"roteamento"| Server254 + HostIP -->|"roteamento"| Server128 + + style WAF fill:#e74c3c,stroke:#c0392b,color:#fff + style NGINX fill:#3498db,stroke:#2980b9,color:#fff + style F2B fill:#27ae60,stroke:#1e8449,color:#fff + style Server128 fill:#9b59b6,stroke:#8e44ad,color:#fff + style Server254 fill:#9b59b6,stroke:#8e44ad,color:#fff + style HostIP fill:#f39c12,stroke:#d68910,color:#fff + style Container1 fill:#1abc9c,stroke:#16a085,color:#fff + style Container2 fill:#1abc9c,stroke:#16a085,color:#fff ``` --- + +## 📋 Sistemas e Servidores Configurados + +Lista de todos os sistemas roteados pelo proxy, organizados por tipo de infraestrutura. + +| Domínio | IP/Backend | Docker | VM | LXC | Descrição | +|---------|------------|:------:|:--:|:---:|-----------| +| `git.itguys.com.br` | 10.10.253.128 | ❌ | ❌ | ✅ | Gitea - Servidor Git | +| `zammad.itguys.com.br` | 172.16.254.59 | ❌ | ❌ | ✅ | Zammad - Helpdesk | +| `monitoramento.itguys.com.br` | 172.16.254.x | ❌ | ❌ | ✅ | Zabbix/Grafana | +| `mimir.itguys.com.br` | 172.16.x.x | ❌ | ❌ | ✅ | Mimir - Métricas | +| `windmill.grupopralog.com.br` | 172.16.253.103:8000 | ❌ | ❌ | ✅ | Windmill - Automação | +| `katalog.itguys.com.br` | 172.16.x.x | ❌ | ❌ | ✅ | Katalog | +| `verbocloud.itguys.com.br` | 172.16.253.13:11580 | ❌ | ❌ | ✅ | Nextcloud AIO | +| `cloud.grupopralog.com.br` | 172.16.253.12 | ❌ | ❌ | ✅ | Nextcloud Pralog | +| `srvoffice001.itguys.com.br` | 172.16.253.101 | ❌ | ✅ | ❌ | Exchange Server | +| `business.itguys.com.br` | 172.16.121.13 | ❌ | ✅ | ❌ | Exchange OWA | +| `vcenter.itguys.com.br` | 172.16.254.110:443 | ❌ | ✅ | ❌ | VMware vCenter | +| `unifi.itguys.com.br` | 172.16.254.123:8443 | ❌ | ✅ | ❌ | UniFi Controller | +| `workspace.itguys.com.br` | 172.16.121.2 | ❌ | ✅ | ❌ | Workspace Windows | +| `vscode.itguys.com.br` | 172.16.x.x | ❌ | ❌ | ✅ | VS Code Server | +| `telefonia.itguys.com.br` | 172.16.x.x | ❌ | ✅ | ❌ | Central Telefônica | +| `proxy.itguys.com.br` | localhost | ✅ | ❌ | ❌ | Este proxy | +| `itguys.com.br` | 172.16.x.x | ❌ | ✅ | ❌ | Site Principal | +| `pralog.com.br` | 172.16.x.x | ❌ | ✅ | ❌ | Site Pralog | +| `anatram.com.br` | 172.16.x.x | ❌ | ✅ | ❌ | Site Anatram | +| `ferreirareal.com.br` | 172.16.x.x | ✅ | ❌ | ❌ | Site Ferreira Real | +| `petytransportes.com.br` | 172.16.x.x | ❌ | ✅ | ❌ | Site Pety Transportes | +| `solucionei.itguys.com.br` | 172.16.x.x | ❌ | ✅ | ❌ | Solucionei | +| `rhema.itguys.com.br` | 172.16.x.x | ❌ | ✅ | ❌ | Rhema | +| `integra.grupopralog.com.br` | 172.16.x.x | ❌ | ❌ | ✅ | Integração Pralog | +| `ns1.itguys.com.br` | 172.16.x.x | ❌ | ❌ | ✅ | DNS Primário | +| `ns2.itguys.com.br` | 172.16.x.x | ❌ | ❌ | ✅ | DNS Secundário | +| `dns-primario.itguys.com.br` | 172.16.x.x | ❌ | ❌ | ✅ | DNS Admin | + +> [!NOTE] +> **Legenda:** Docker = Container Docker | VM = Máquina Virtual (VMware/Hyper-V) | LXC = Linux Container (Proxmox) +> +> IPs marcados como `172.16.x.x` precisam ser verificados nos arquivos de configuração individuais. + +--- + *Mantido por IT Guys* \ No newline at end of file diff --git a/conf.d/test-connectivity.conf b/conf.d/test-connectivity.conf new file mode 100644 index 0000000..b7a5337 --- /dev/null +++ b/conf.d/test-connectivity.conf @@ -0,0 +1,45 @@ +# ============================================================================== +# ARQUIVO TEMPORÁRIO: Teste de Conectividade +# REMOVER APÓS VALIDAÇÃO DA TAREFA 4 +# ============================================================================== + +server { + listen 8080; + server_name localhost test-connectivity; + + # Health check simples + location /health { + return 200 "OK - nginx-proxy respondendo\n"; + add_header Content-Type text/plain; + } + + # Teste 1: Ping para 10.10.253.254 + location /test/254 { + proxy_pass http://10.10.253.254/; + proxy_connect_timeout 5s; + proxy_read_timeout 10s; + error_page 502 504 = @test_failed; + } + + # Teste 2: Ping para 10.10.253.128 (Gitea - porta 3000) + location /test/128 { + proxy_pass http://10.10.253.128:3000/; + proxy_connect_timeout 5s; + proxy_read_timeout 10s; + error_page 502 504 = @test_failed; + } + + # Teste 3: Acesso via host.docker.internal (rede do host) + location /test/host { + # Tenta acessar a porta 80 do próprio host + proxy_pass http://host.docker.internal/; + proxy_connect_timeout 5s; + error_page 502 504 = @test_failed; + } + + # Fallback para testes que falharam + location @test_failed { + return 503 "FALHA: Não foi possível conectar ao backend\n"; + add_header Content-Type text/plain; + } +} diff --git a/docker-compose.yml b/docker-compose.yml index 668d649..1996f71 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -22,6 +22,7 @@ services: depends_on: - nginx-proxy extra_hosts: + - "host.docker.internal:host-gateway" - "srvproxy001.itguys.com.br:172.16.254.1" - "srvproxy001:172.16.254.1" - "git.itguys.com.br:10.10.253.128" @@ -53,6 +54,21 @@ services: - nginx_logs:/var/log/nginx - ./certbot/conf:/etc/letsencrypt - ./certbot/www:/var/www/certbot + extra_hosts: + - "host.docker.internal:host-gateway" + - "server-254:10.10.253.254" + - "gitea-server:10.10.253.128" + - "srvproxy001.itguys.com.br:172.16.254.1" + - "srvproxy001:172.16.254.1" + - "git.itguys.com.br:10.10.253.128" + - "git:10.10.253.128" + - "zammad.itguys.com.br:172.16.254.59" + - "zammad:172.16.254.59" + - "cloud.grupopralog.com.br:172.16.253.12" + - "business.itguys.com.br:172.16.121.13" + - "verbocloud.itguys.com.br:172.16.253.13" + - "srvoffice001.itguys.com.br:172.16.253.101" + - "srvoffice001:172.16.253.101" # ============================================ # Fail2ban (Lê logs e bane IPs) diff --git a/snippets/docker_resolver.conf b/snippets/docker_resolver.conf new file mode 100644 index 0000000..04fc90b --- /dev/null +++ b/snippets/docker_resolver.conf @@ -0,0 +1,11 @@ +# Docker DNS Resolver +# Use dentro de location blocks quando precisar resolver +# nomes de containers dinamicamente (ex: com variáveis) +# +# Uso: +# set $backend "container-name:port"; +# include /etc/nginx/snippets/docker_resolver.conf; +# proxy_pass http://$backend; + +resolver 127.0.0.11 valid=30s ipv6=off; +resolver_timeout 5s;