GithubHelp home page GithubHelp logo

yangkghjh / autoindex Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nielsad/autoindex

0.0 1.0 0.0 61 KB

Lightweight go web server that provides a searchable directory index.

License: Mozilla Public License 2.0

Go 75.60% HTML 3.63% JavaScript 11.45% CSS 8.63% Dockerfile 0.52% Makefile 0.18%

autoindex's Introduction

autoindex

License: MPL 2.0

Lightweight go web server that provides a searchable directory index. Optimized for handling large numbers of files (100k+) and remote file systems (with high latency) through a continously updated directory cache.

Live demo

Features:

  • Lightweight single-page application (~8KB html/css/js)
  • Responsive design
  • Recursive file search
  • Directory cache (sqlite)
  • Sitemap support

Usage

./autoindex [options]

Flag Type Description
-a string TCP network address to listen for connections
-d string Database location
-r string Root directory to serve
-i string Refresh interval
-l int Request rate limit (req/sec per IP)
-t duration Request timeout
-forwarded bool Trust X-Real-IP and X-Forwarded-For headers
-cached bool Serve everything from cache (rather than search/recursive queries only)

Example

./autoindex -a=":4000" -i=5m -d=/tmp/autoindex.db -cached -r=/mnt/storage

Behind nginx

Example configuration for running autoindex behind an nginx proxy.

upstream autoindex {
    server 127.0.0.1:4000;
    keepalive 8;
}

map $request_uri $request_basename {
    ~/(?<captured_request_basename>[^/?]*)(?:\?|$) $captured_request_basename;
}

map $request_uri $idx_path {
    ~/(?<captured_request_args>\?.*)?$                                $captured_request_args;
    ~/(?<captured_request_path>[^?]*)(?<captured_request_args>\?.*)?$ $captured_request_path/$captured_request_args;
}

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name _;

    root /opt/autoindex/public;

    location / {
        rewrite ^/(.*)/$ /$1 permanent;
        try_files $uri /index.html;
        expires 1y;
    }

    location = /index.html {
        http2_push /idx/$idx_path;
        expires 1d;
    }

    location ^~ /dl/ {
        limit_rate 1m;
        add_header Content-Disposition 'attachment; filename="$request_basename"';
        add_header X-Robots-Tag "noindex, nofollow, nosnippet, noarchive";
    }

    location ~ ^(/idx/|/urllist.txt) {
        proxy_pass http://autoindex;
    }
}

autoindex's People

Contributors

nielsad avatar yangkghjh avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.