Reputation: 7906
I have 2 folders like folder-a and folder-b and they are shown as part of the Nginx file explorer. I have my Nginx file below. I have a problem statement like folder-a and folder-b sometimes share common sub-directory with different content like
folder-a->sub-folder->1.txt
folder-b->sub-folder->2.txt
so when the user is viewing folder folder-a->sub-folder or folder-b>sub-folder he should be able to see both 1.txt and 2.txt i.e. it should feel like a unified view. Can I achieve this is nginx?
worker_processes 1;
events { worker_connections 1024; }
http {
include /etc/nginx/mime.types;
server {
server_name localhost;
listen 80;
root /usr/share/nginx/html;
autoindex on;
autoindex_exact_size off;
autoindex_localtime on;
location ~ ^/folder-a/(.+)$ {
error_page 404 @redirect;
}
location @redirect {
return 301 /folder-b/$1;
}
}
}
Upvotes: 0
Views: 470
Reputation: 3071
Not tested but as we can specify the output format of the autoindex there may be solutions / configuration to print create a new directory listing.
http://nginx.org/en/docs/http/ngx_http_autoindex_module.html
But it will always "print / show" the current folders content. Given that if you want to combine the filelist of two different folders njs
could help here.
Something like a server that is configured with autoindex = on
and a useable format like json
or xml
. njs
could query both directories and reconstruct a new output (xml, json).
Not tested just a fancy idea.
Upvotes: 0