我需要使用 nginx 提供大约 70,000 个静态文件 (jpg)。我应该将它们全部转储到一个目录中,还是有更好(有效)的方法?由于文件名是数字,我考虑使用如下目录结构:
xxx/xxxx/xxx
操作系统为 CentOS 5.1
我在服务器上以测试模式部署了一个应用程序。对它的访问仅限于通过 HTTP 身份验证的选定用户组。这很好用。问题是,如果我通过不同的“位置”指令提供静态文件,nginx 会为这些文件提供“未授权”。我尝试关闭 auth_basic,但没有骰子。
这是 vhost conf:
# Virtual Host
upstream appname {
server 127.0.0.1:4000;
server 127.0.0.1:4001;
server 127.0.0.1:4002;
}
server {
listen 80;
server_name appname.domain.com;
# write app specific log
# make sure you create this file in your log directory before running behind nginx
access_log /home/apps/appname/shared/log/nginx.log main;
# let nginx serve static files directly
# images
location ^~/images {
auth_basic off;
root /home/apps/appname/current/public/images;
}
location ^~/covers {
auth_basic off;
root /home/apps/covers;
}
# # javascript
location ^~/javascripts …Run Code Online (Sandbox Code Playgroud) configuration nginx authentication http-basic-authentication