Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

235
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda