autoindex subdirectories
Igor A. Ippolitov
iippolitov at nginx.com
Thu May 9 21:35:23 UTC 2019
Hello, guys.
I think I have a POC using autoindex, ssi and xslt. Obviously it
requires further tweaking.
You can use configuration like this:
> map $uri $doc {
> ~*/index[^/]*(.*) $1;
> }
> server {
> listen 8080;
> proxy_http_version 1.1;
> location /index/ {
> alias /tests/nginx;
> ssi on;
> proxy_pass http://localhost:8080/index2/;
> }
> location /index2 {
> autoindex on;
> autoindex_format xml;
> xslt_string_param base /index/$doc;
> xslt_stylesheet /tests/nginx/req.index.xslt;
> alias /tests/nginx;
> }
> }
> }
Along with a simple xslt like this:
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> exclude-result-prefixes="xsl"
> >
> <xsl:param name="base"/>
>
> <xsl:output method="html" omit-xml-declaration="yes"/>
> <xsl:template match="//directory">
> <xsl:value-of select="."/>
> |-><xsl:comment># include virtual="<xsl:value-of
> select="$base"/><xsl:value-of select="."/>/" </xsl:comment>
> </xsl:template>
>
> </xsl:stylesheet>
And this will make nginx do recursive listing but the resulting output
is far from ideal.
Also no error handling is done (should be done using error_page).
Regards,
Igor.
On 09.05.2019 3:26, Patrick wrote:
> On 2019-05-09 08:48, Duke Dougal wrote:
>> Is there any way to get autoindex to return a recursive list of
>> files/directories?
> What modules do you have available to work with?
>
> Just using default built modules, there doesn't seem to be a way.
>
> Using non-default modules, you could use:
>
> 1) ngx_http_perl + some perl
>
> 2) ngx_http_addition + some javascript added to the page to ajax query
> and rewrite the page
>
> 3) the 3rd-party lua module + some lua
>
>
> While it's definitely a hack, option #2 seems the best unless you need
> to cater to javascript-less clients.
>
> Anyone see a cleaner solution?
> _______________________________________________
> nginx mailing list
> nginx at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
More information about the nginx
mailing list