Skip to content

How do I restrict access to the Magento2 background address using HTTP basic authentication

How do I restrict access to the Magento2.4 backend using HTTP basic authentication。
All I know is to restrict access to Magento2.4’s entire site with HTTP basic authentication
, as follows:

in nginx.conf.sample

location / {
try_files $uri $uri/ /index.php$is_args$args;
auth_basic "Restricted";
auth_basic_user_file /etc/apache2/.htpasswd;     

}

For example, the website www.abc.com can restrict access, but I want www.abc.com to not restrict normal access, I want to restrict access to the background address www.abc.com/admin, how should I operate, anyone know, please leave a message to me, thank you very much!