I am using below command to create a simple http server so that end users can download files on the unix server directly using the URL. But this is kinda risky and i need to implement a user restriction process so that security is not compromised.
python -u -m http.server 8000 &> log_file & echo $! > pid_file
My plan is to capture the userids/usernames in the logs and then use a logic to ban those users from accessing the webserver session. But I am stuck at capturing the userids/names. Is there a way to implement this ? Or anybody has any other ways to achieve the end goal?
cat log_file
10.166.00.000 - - [16/Feb/2023 03:54:14] "Get / HTTPS/1.1" 200 - 10.166.22.000 - - [16/Feb/2023 03:54:14] "Get /Folder HTTPS/1.1" 200 -
expected output ~ something like this maybe, or as long as it captures username
10.166.00.000 - username1 - [16/Feb/2023 03:54:14] "Get / HTTPS/1.1" 200 - 10.166.22.000 - username2 - [16/Feb/2023 03:54:14] "Get /Folder HTTPS/1.1" 200 -