Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

518
Visualizações
Nginx map: regex to check substring

I have a Nginx service that serves an application. This application sends requests often, because of that, there are a lot of log messages inside my access.log file.

For that reason, I'm trying to create a Conditional Logging to avoid to save these unnecessary log messages.

Based on the documentation, I've tried to create a regex to check if the request contains a substring, but it did not work.

I believe my $request variable should be a request like this one:

GET /catalog-dash/_reload-hash HTTP/1.1

I would like to check if my $request variable contains the _reload-hash substring.

I've created the code below, but it did not work, unfortunately.

map $request $loggable {
    ~/_reload-hash/  0;
    default 1;
}

access_log /path/to/access.log combined if=$loggable;

If someone could help me, I would appreciate it.

Thank you in advance.

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

I believe before asking the question I did not use the correct keys to search the answer on the internet.

Some minutes after asking the original question I've found this answer that has solved my problem.

I send below the changes I did to work and I hope it could help others in the future.

map $request_uri $loggable {
    ~^.*_reload-hash.*$  0;
    default 1;
}

Thank you Richard for your tip of using $request_uri instead of $request.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda