Search code examples
chttpauthenticationnginxbasic-authentication

nginX custom HTTP authorization , using scripts to decide


i want to protect some files in a folder by requiring passwords for download however list of users that are allowed to download are on a mysql table with their passwords in md5 format (which means i cannot generate a htpasswd file)

to make it harder i also need to allow some users to download some files and others to download other files without being able to move files (separating files in multiple folders)

so i what i need is some kind of auth api , when there is a request nginx askes a Script (lets say a php script) with parameters of username/password/ip/filename and depending on script's response allow or disallow the download

is this possible?

what i've done so far:

1.looking in the 3rd party modules list http://wiki.nginx.org/3rdPartyModules where i found a module with PAM but my server is windows

2.googling lots of terms without any results

3.looking at the module development tutorials http://www.evanmiller.org/nginx-modules-guide.html

i'm not really good at C so a pre made module for windows that bounces the request to a script (without proxy-ing the download through it) is the best if not some pointers to how should i make a module that meets my requirements is appreciated .


Solution

  • You can use the http_auth_request module.

    p.s. Do you actually know that nginx for windows is not production ready?