Caddy filebrowser rewrite


(xincun) #1

https://caddy.community/t/how-to-achieve-page-access-only-by-lan/3606/17

Very happy filebrowser 2.0 release.
Tracked web requests.

log stdout

Snipaste_2019-01-24_01-13-24

The difference is resource becomes resources .
After modifying rewrtie, the home page got a black screen and could not do anything.

It seems that rewrite won’t jump?
Folder structure: C:…\Desktop\www\test, All the files needs to share are in test folder.

rewrite { 
if {path} ends_with resources/
to /api/resources/test
}

rewrite { 
if_op and
if {path} has resources
if {path} not_ends_with resources/
if {path} not_has test
to /forbidden
}

@hacdias


(Henrique Dias) #2

Hey! A black screen? Could you take a screenshot please?


(xincun) #3

It seems that the home page has opened an unknown file and cannot be cancelled. The X in the upper left corner is invalid.

Delete two rewrites, everything works fine.
URL manually enter files/test, everything works fine.


(xincun) #4

No matter how you rewrite the path, the home page will not execute, always /api/resources/. All other modules have been blocked.

Tested v2 2.0.1 2.0.2

@hacdias, v1 is running very well. I want to rewrite all path to /api/resources/test


(Henrique Dias) #5

I wouldn’t recommend you to do those rewrites. Probably that’s why you’re having issues. Why do you need that?


(xincun) #6

I need these rewrites to force the filebrowser directory to be restricted to the /test/ directory, because the filebrowser permissions are very high, and the admin permissions can control the entire server.
Just change the directory range in the settings, fill in the absolute path, you can read and write to the server’s system directory or root directory. It is not controlled by the root setting of the caddyfile at all.

These two very simple path rewrites, no problems with v1 support.