title: Nginx: Prevent direct access to static files
body: <p>I've been searching for a while now but didn't manage to find anything that fits my needs. I don't need hotlinking protection, as much as I'd like to prevent people from directly accessing my files. Let's say:</p>
  
  <p>My <code>website.com</code> requests <code>website.com/assets/custom.js</code>, that'd work,but I'd like visitors which directly visit this file to get a <code>403 status code</code> or something. I really have no idea if it's possible, and I don't have any logical steps in mind..</p>
  
  <p>Regards !</p>