In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces how Nginx allows users to access the web site through user name and password authentication related knowledge, the content is detailed and easy to understand, the operation is simple and fast, with a certain reference value, I believe that after reading this Nginx how to let users access the web site through user name and password authentication will have a harvest, let's take a look at it.
Experimental environment:
Now the company has launched an internal website for www1.rsyslog.org, which requires everyone to enter a user name and password before viewing the web page.
Use the construction of virtual host under nginx
Www1.rsyslog.org carries on the test.
Www1.rsyslog.org 192.168.100.107
Dns1 192.168.100.102
First, view the current system parameters
[root@rhel6u3-2 ~] # uname-r / / View system kernel version 2.6.32-279.el6.i686 [root@rhel6u3-2 ~] # cat / etc/redhat-release / / View system version number redhat enterprise linux server release 6.3 (santiago)
2. Edit the virtual host configuration file
Add the following statement to the http field in the [root@rhel6u3-7 ~] # vim / usr/local/nginx/conf/nginx.conf / / main configuration file to point the configuration file of the virtual host to www1.rsyslog.org include / usr/local/nginx/server/www1.rsyslog.org; [root@rhel6u3-7 ~] # vim / usr/local/nginx/server/www1.rsyslog.org server {listen 80; / / the listening port is 80 server_name www1.rsyslog.org / / Virtual host URL location / {root sites/www1; / / Virtual host website root directory index index.html index.htm; / / Virtual host home page auth_basic "secret"; / / Virtual host authentication named auth_basic_user_file / usr/local/nginx/passwd.db / / Virtual host username and password authentication database} location / status {stub_status on; / / enable website monitoring status access_log / usr/local/nginx/logs/www1_status.log; / / monitoring log auth_basic "nginxstatus";}}
Third, generate the user name and corresponding password database file through the htpasswd command.
[root@rhel6u3-7 server] # htpasswd-c / usr/local/nginx/passwd.db xiaonuo / / create authentication information Xiaonuo is the authentication username new password: * / / enter the authentication password re-type new password: * / / enter the authentication password adding password for user xiaonuo [root@rhel6u3-7 server] # [root@rhel6u3-7 ~] # chmod 400 / usr/local/nginx/passwd.db / / modify the website authentication database permission [root@rhel6u3-7 ~] # chown nginx. / usr/local/nginx/passwd.db / / modify the website authentication database owner and group [root@rhel6u3-7] # cat / usr/local/nginx/passwd.db / / you can see that the password generated through htpasswd is in the encrypted format xiaonuo:8ezaz7bqcrxmy [root@rhel6u3-7 ~] #
IV. Restart the nginx service smoothly
[root@rhel6u3-7 ~] # / etc/rc.d/init.d/nginx reload / / smoothly restart the nginx service nginx: the configuration file / usr/local/nginx/conf/nginx.conf syntax is ok nginx: configuration file / usr/local/nginx/conf/nginx.conf test is successful reloading nginx: [ok]
Add www1 a records to the dns server
Www1 a 192.168.100.107
6. Visit www1.rsyslog.org through ie for testing.
Don't forget to point the preferred dns of the network card to 192.168.100.102
This is the end of the article on "how Nginx allows users to access web sites through username and password authentication". Thank you for reading! I believe that everyone has a certain understanding of "how Nginx allows users to access web sites through user name and password authentication". If you want to learn more, you are welcome to follow 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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.