rejetto forum
Software => HFS ~ HTTP File Server => Topic started by: Tsuna on April 28, 2021, 01:52:15 PM
-
Using the latest dev version and having a roadblock where I want to limit a folder such that only a specific IP can view it/access it
But unable to find anything like this in the docs or on the forum
I think it may be possible via a script for that folder? Looking for some guidance on the same
-
Right click on your folder, select "Properties...", then go to "Diff template" tab, put in these:
[^]
{.if|{.!=|%ip%|192.168.2.149.}|
{:{.disconnect.}:}
.}
(replace the ip to yours)
Push OK then it works ;)
-
It works:
[+]
{.if|{.!=|%ip%|127.0.0.1.}|{:{.disconnect.}:}.}
-
Not working. REEEEEEE
I want that the file can be only accessed by a specific IP I want.
like a folder's file can be accessed through 1.1.1.1 nor can access the file.
-
if only one particular ip should be able to access the folder, add something similar in the diff template of the folder properties
either by using a forced disconnection
[+]
{.if|{.=|%ip%|127.0.0.1.}|{:{.disconnect.}:}.}
or even better by using a redirect which gives the user the impression of an invalid link
[+]
{.if|{.=|%ip%|127.0.0.1.}|{:{.redirect|../ .}:}.}
replace 127.0.0.1 by the allowed ip
a more concrete example is to only give access to a specific user without going through permissions
[+]
{.if|{.!=|%user%|Tsuna.}|{:{.redirect|../ .}:}.}
note the difference in use between {.!=| and {.=| , difference or equal usage
-
...the file can be only accessed by a specific IP...
At HFS console, press alt+f6 to edit events file, and add this: [download]
{.if|{.match|myparticularfile.doc|%url%.}|{:{.if|{.!=|%ip%|127.0.0.1.}|{:{.disconnect.}:}.}:}.}
replace myparticularfile.doc with target file name (to block for most)
replace 127.0.0.1 with target IP address (to allow for one)
P.S. Other options instead of myparticularfile.doc may be /folder* or *.doc and you can even add to the list, such as myparticularfile.doc;myotherfile.txt;*.pdf with semicolon in-between.
P.P.S. If this method seems clunky, then you could use the more normal and flexible users/groups/passwords, located in hfs menu > other options > user accounts. And, then you can right-click on a particular folder/file to set it private to your users/groups.