Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

236
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!