Skip to content

fix(decoredirect): use configuration-snippet to avoid breaking ACME challenges#24

Merged
igoramf merged 1 commit into
mainfrom
fix/decoredirect-configuration-snippet-redirect
Jun 18, 2026
Merged

fix(decoredirect): use configuration-snippet to avoid breaking ACME challenges#24
igoramf merged 1 commit into
mainfrom
fix/decoredirect-configuration-snippet-redirect

Conversation

@igoramf

@igoramf igoramf commented Jun 18, 2026

Copy link
Copy Markdown
Collaborator

Problema

O PR #23 usou server-snippet para preservar o path no redirect. Porém o server-snippet roda no bloco server do nginx (tanto HTTP quanto HTTPS) antes do location matching — isso intercepta as requisições do Let's Encrypt HTTP-01 ACME challenge e quebra a emissão de certificados para novos domínios.

Confirmado em produção: http://zeenow.com.br/.well-known/acme-challenge/TOKEN retornava 307 para https://www.zeenow.com.br/... em vez de servir o token.

Fix

configuration-snippet injeta o return no bloco location / em vez do bloco server. O ACME solver do cert-manager cria um location mais específico (/.well-known/acme-challenge/TOKEN) que tem prioridade sobre o location / — então o challenge é servido corretamente enquanto todos os outros paths continuam sendo redirecionados com o path preservado.

server-snippet     → roda antes do location matching → quebra ACME ❌
configuration-snippet → roda no location /           → ACME solver ganha ✓

Test plan

  • Testes unitários passando (14/14)
  • Após deploy, validar que zeenow.com.br emite certificado
  • Validar que oscarcalcados.com.br/promocao-botas ainda redireciona com path preservado

🤖 Generated with Claude Code


Summary by cubic

Switch redirect annotation to NGINX Ingress configuration-snippet so ACME HTTP-01 challenges are not intercepted, restoring certificate issuance for new domains. Redirects still preserve path and query via $request_uri.

  • Bug Fixes
    • Replace nginx.ingress.kubernetes.io/server-snippet with nginx.ingress.kubernetes.io/configuration-snippet to scope the return to location /, allowing cert-manager’s /.well-known/acme-challenge/* location to win.
    • Update controller and tests to expect the new annotation; default 307 is preserved and 301 is used when specified.

Written for commit 9f89844. Summary will update on new commits.

Review in cubic

server-snippet runs at the nginx server block level (HTTP + HTTPS) before
location matching, intercepting Let's Encrypt HTTP-01 ACME challenge
requests and breaking certificate issuance for new domains.

configuration-snippet is scoped to the location / block — the cert-manager
ACME solver creates a more specific location (/.well-known/acme-challenge/TOKEN)
that takes priority, so challenges are served correctly while path is
still preserved via $request_uri on all other requests.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@igoramf igoramf merged commit deb35fe into main Jun 18, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant