开发者

Restrict file access with nginx and javascript

I have several javascript projects served by nginx. The project directory is structured as this way: images/, javas开发者_如何学编程cripts/, 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?


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;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜