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

243
Visualizações
How to block JS files in Nginx

what I want to do is to return internal (404) when a specific JS file is being used.

For example:

I have this block of code:

location ~* /something.min.js?id=c34f7s-d87a9-rthg76s {
    internal;
}

which is written in some_name.conf file. That file is being included in the conf.d folder in a specific .conf file.

So far everything works just fine, nxing -t validates the configuration. But when I open the specific url in a browser it still works, so nothing changed.

I am new to nginx, so I was really desperate and tried following options too:

^~ /something.min.js?id=c34f7s-d87a9-rthg76s
/something.min.js?id=c34f7s-d87a9-rthg76s
= /something.min.js?id=c34f7s-d87a9-rthg76s
~* /something.min.js?id=c34f7s-d87a9-rthg76s

but none of them seemed to be working. So is there any other way how I could return 404 and stop the particular js file from working?

The only thing that really worked was, when I had a path like this:

/js/something?something=som.Something.setSomething

and used:

location /js/ {
    deny all;
}

but of course that stops everything inside /js, not the specific file I want.

Thank you for your help!

about 4 years ago · Juan Pablo Isaza
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