contrib icon indicating copy to clipboard operation
contrib copied to clipboard

static: Can't disable file listing

Open elimisteve opened this issue 10 years ago • 3 comments

When visiting /static/ on a webserver that uses https://github.com/gin-gonic/contrib/blob/master/static/static.go to handle requests to /static/*, I see a file listing. For security purposes, I would like to disable this.

Any thoughts on how to securely do this? Thanks!

/cc @ajvb

elimisteve avatar Mar 09 '15 20:03 elimisteve

@elimisteve

r.Use(static.Serve("/static/", static.LocalFile("/yourdirectory", false)))

iwanbk avatar Dec 24 '15 04:12 iwanbk

@elimisteve

I recently started using contrib/static but discovered the second paramter called "indexes" behaves a little differently to me and I am wondering if it's a bug.

With indexes set to false it won't give directory listings as expected, but it also won't automatically serve up index.html if you go to /static/ for example and there is an index.html file there.

I think this is a bug.

With indexes set to true it serves up directory listings AND going to /static/ automatically opens index.html

I think it's not right that the indexes flag controls both directory listing AND whether index.html should be loaded automatically, it seems like a bug to me and this needs to be a second argument really.

robvdl avatar Dec 24 '15 09:12 robvdl

+1 for index.html

giter avatar Oct 21 '16 06:10 giter