Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize login authentication by configuring Basic Auth in Nginx

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article shows you how to configure Basic Auth to achieve login authentication in Nginx, the content is concise and easy to understand, absolutely can make you shine, through the detailed introduction of this article I hope you can gain something.

1. Make sure you have httpd-tools installed

yum install httpd-tools -y

2. Create authorized users and passwords

htpasswd -c -d /usr/local/openresty/nginx/conf/pass_file magina

This configuration file storage path can be arbitrarily specified, here I specify is the nginx configuration file directory, where magina refers to the user name allowed to log in, this can be customized

3. configure Nginx

The general configuration is as follows:

server { listen 80; server_name res.yinnote.com; auth_basic "login authentication"; auth_basic_user_file /usr/local/openresty/nginx/conf/pass_file; autoindex on; autoindex_exact_size on; autoindex_localtime on; root /mnt/html/resource; index index.html index.php;}

auth_basic and auth_basic_user_file are authentication configurations, note that the path to the password file must be generated above

4. use

#In the browser, enter the address directly in the browser, and the user password input box will pop up. Enter it to access #Use wgetwget --http-user=magina --http-passwd=123456 http://res.yinnote.com/xxx.zip# Use curlcurl -u magina:123456 -O http://res.yinnote.com/xxx.zip The above content is how to configure Basic Auth in Nginx to achieve login authentication. Have you learned knowledge or skills? If you want to learn more skills or enrich your knowledge reserves, please pay attention to the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report