This tutorial is for making a simple authentication on your site via nginx using mysql.
This tutorial is assuming that you already have:
- nginx installed
- have a virtual host already setup on nginx config
- mysql installed
sudo su
apt-get install nginx-extras libpam-mysql
open your virtual host config file
nano /etc/nginx/site-available/your-site
add this statement on your server configuration
auth_pam "Restricted Zone";
auth_pam_service_name "your-service-name";
create file that match your-service-name
nano /etc/pam.d/your-service-name
add this statement
auth required pam_mysql.so user=db_user passwd=db_pass host=127.0.0.1 db=mail table=users usercolumn=email passwdcolumn=password crypt=3
account sufficient pam_mysql.so user=db_user passwd=db_pass host=127.0.0.1 db=mail table=users usercolumn=email passwdcolumn=password crypt=3
note that you must adjust this statement based on your mysql host, user, password, table, and coloumn you want to use. This statement works with md5 password encryption.
service nginx restart
all done!