In my /etc/nginx/sites-available/default file I currently have blocks along the lines of

 location /cdn
  add_header Access-Control-Allow-Origin *;

which has worked well - up until now. However, I now find myself creating sub directories below /cdn which throws up CORS errors on the browser when I try to access resources in, say /cdn/appdata/icons. I could quite easily bung in a few more blocks similar to the one above but targeting /cdn/appdata etc. However, this would be a short term solution liable to break sooner rather than later.

Is there a way to specify a location block for a folder and ALL its subfolders?

  • 1
    The location in your question does that already, unless a more specific location matches. Jan 20 at 15:38
  • Please share the output of nginx -T to show the full nginx configuration. Jan 21 at 17:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.