Dou*_*eri 5 server-configuration nginx
我安装了nginx 1.0.8.这是我的问题:我有2个文件:file1.js和file2.js.请求的路径是这样的:
www.mysite.com/files_dir/%user%/file.js
如果请求的标题:" X-Header "存在且值为" OK ",则响应的内容应为file1.js else file2.js.
这些文件位于" html/files_dir "中,%user%是一组目录,表示通过我的服务注册的用户名.
如何在nginx中配置?我对php,asp或类似技术不感兴趣只有在nginx可能的情况下才有意义.
谢谢
map
允许您根据另一个变量定义变量的值.map
应在http
级别(即在...之外server
)声明:
map $http_x_header $file_suffix {
default "2";
OK "1";
};
Run Code Online (Sandbox Code Playgroud)
然后以下location
应该使用您的新变量来完成这个技巧$file_suffix
location ~ ^(/files_dir/.+)\.js$ {
root html;
try_files $1$file_suffix.js =404;
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
15359 次 |
最近记录: |