开发者

Restrict file access with nginx and javascript

开发者 https://www.devze.com 2023-01-14 02:01 出处:网络
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 a

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

精彩评论

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