javascript - nginx deny access to JS and CSS -


i have webpage set using node.js set behind nginx. everythings work fine, block direct public access css , js files

in nginx config have this:

location /style/ {         deny all;     }  location /js/ {         deny all;     } 

it correctly block access - when view source on webpage , try navigate directly css or linked js files 403 error. however, prevents node/nginx being able correctly use files style/add functionality page

what correct way prevent people directly accessing files, while still being able use them display page itself?

there isn't way.

either browser can access file , use in page, or can't access file @ all.

you try using referer request header, you'll false negatives , people have downloaded page have access js anyway (either cache or script tab in browser's developer tools).


Comments

Popular posts from this blog

python - Healpy: From Data to Healpix map -

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -