feat(rede): Implementa conectividade com redes Docker internas e IPs externos
## Tarefa 4 - Conexão Direta na Interface do Host ### Alterações no Docker Compose - Adicionado host.docker.internal:host-gateway no modsecurity e nginx-proxy - Permite acesso à rede física do host para alcançar IPs externos (10.10.253.x) - Adicionados mapeamentos extras para server-254 e gitea-server ### Novos Arquivos - snippets/docker_resolver.conf: Resolver DNS Docker para containers dinâmicos - conf.d/test-connectivity.conf: Endpoints temporários para validar conectividade (REMOVER após testes no host de deploy) ### Documentação - README.md: Diagrama de arquitetura atualizado com cores mais legíveis - README.md: Adicionada tabela de sistemas/servidores (Docker/VM/LXC) - TODO.md: Status da tarefa 4 atualizado para 'Aguardando Teste' ### Próximos Passos (no host de deploy) 1. docker compose build --no-cache nginx-proxy 2. docker compose down && docker compose up -d 3. Testar ping para 10.10.253.254 e 10.10.253.128 4. Remover test-connectivity.conf após validação
This commit is contained in:
parent
3a5d73a485
commit
0ee283eab1
|
|
@ -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.
|
||||
|
||||
|
|
|
|||
97
README.md
97
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
|
||||
|
||||
Logs[Logs Compartilhados]
|
||||
WAF -.-> Logs
|
||||
Proxy -.-> Logs
|
||||
subgraph Host["Host Docker (Portainer)"]
|
||||
subgraph PathfinderStack["Stack: Pathfinder-Proxy<br/>Rede: 172.112.0.0/16"]
|
||||
WAF["ModSecurity WAF<br/>172.112.0.3<br/>:80, :443"]
|
||||
NGINX["nginx-proxy<br/>172.112.0.2<br/>:8080 interno"]
|
||||
F2B["fail2ban<br/>network: host"]
|
||||
end
|
||||
|
||||
F2B[Container Fail2ban]
|
||||
F2B -- Lê --> Logs
|
||||
F2B -- Bane IP --> WAF
|
||||
subgraph HostNetwork["Rede Física do Host"]
|
||||
HostIP["host.docker.internal<br/>(gateway)"]
|
||||
end
|
||||
|
||||
subgraph OtherStacks["Outras Stacks Docker"]
|
||||
Container1["Container A<br/>172.111.0.x"]
|
||||
Container2["Container B<br/>172.113.0.x"]
|
||||
end
|
||||
end
|
||||
|
||||
subgraph ExternalServers["Servidores Externos"]
|
||||
Server254["10.10.253.254"]
|
||||
Server128["10.10.253.128<br/>Gitea"]
|
||||
end
|
||||
|
||||
Client -->|":80/:443"| WAF
|
||||
WAF -->|"proxy_pass :8080"| NGINX
|
||||
F2B -.->|"lê logs"| WAF
|
||||
F2B -.->|"lê logs"| NGINX
|
||||
|
||||
NGINX -->|"extra_hosts<br/>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*
|
||||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
Loading…
Reference in New Issue