Answer the question
In order to leave comments, you need to log in
How to make access control to the site in Nginx?
Good day. Developed a site using Asp.net core, which consists of two parts.
1- The admin panel of an employee who will enter certain data and work with the database (mysite.com)
2-Api, with the help of which another user receives data from the database (mysite.com/api)
The task is this. It is necessary to differentiate access to the site from outside. So that access to the site api (mysite.com/api) is possible from outside, and access to the admin panel is only inside the network (from allowed addresses)
Answer the question
In order to leave comments, you need to log in
Password-protect access to the admin panel.
location ~* ^/admin {
auth_basic "Admin page";
auth_basic_user_file /etc/nginx/nginx.pass;
}
LOGIN="admin"
PASSWORD="pass"
OPENSSL=`echo "${PASSWORD}" | openssl passwd -1 -stdin -salt Nginx`
echo "${LOGIN}:${OPENSSL}" >> /etc/nginx/nginx.pass
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question