views:

17

answers:

1

I have several javascript projects served by nginx. The project directory is structured as this way: images/, javascripts/, css/, and index.html. On the production server, I combine and minify all js and css files (app_min.js & app_min.css) into only two files. However, I want to restrict all files (except images directory, app_min.js, app_min.css, and index.html) on the production server. Here is my simple nginx configuration:

location /opa {
   alias /var/www/project_a/;
   index index.html;
   break;
}

Anyone could explain me how to implement this?

A: 

I can be wrong, but maybe something like this:

location ~ ^(/opa/images/.*|/opa/app_min\.js|/opa/app_min\.css|/opa/index\.html)$ {
    alias /var/www/projecta_a/;
    index index.html;
    allow all;
}

location / {
    deny all;
}
floatless
any other solutions beside this?
Chamnap
Yes. Try to `chmod` all files that you want to hide, so Nginx will not be able to read them.
floatless