In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces the "user authentication configuration in Nginx and how to prevent users from using agents to access" related knowledge, Xiaobian shows you the operation process through the actual case, the method of operation is simple and fast, practical, hope that this "user authentication configuration in Nginx and how to prevent users from using proxy access" article can help you solve the problem.
Nginx user Authentication configuration (basic http authentication)
The ngx_http_auth_basic_module module implementation allows access to web content only if the correct user password is entered. There are some things on web that you don't want others to know, but you want some people to see them. Nginx's http auth module and apache http auth are good solutions.
Nginx already has the ngx_http_auth_basic_module module installed by default, and if you don't need this module, you can add-- without-http_auth_basic_module.
Nginx basic auth instruction
Syntax: auth_basic string | off
Default value: auth_basic off
Configuration segment: http, server, location, limit_except
The default means that authentication is not enabled, and if followed by characters, these characters will be displayed in the pop-up window.
Syntax: auth_basic_user_file file
Default value:-
Configuration segment: http, server, location, limit_except
User password file, which is similar to the following:
Ttlsauser1:password1
Ttlsauser2:password2:comment
Nginx authentication configuration instance
Server {server_name www.jb51.net jb51.net; index index.html index.php; root / data/site/www.jb51.net; location / {auth_basic "nginx basic http test for jb51.net"; auth_basic_user_file conf/htpasswd; autoindex on;}}
Note: be sure to pay attention to the auth_basic_user_file path, otherwise 403 will appear at great pains.
Generate password
You can use htpasswd or openssl
# printf "ttlsa:$ (openssl passwd-crypt 123456)\ n" > > conf/htpasswd# cat conf/htpasswd ttlsa:xyjkvhxgaz8tm
Account number: ttlsa
Password: 123456
Reload nginx
# / usr/local/nginx-1.5.2/sbin/nginx-s reload
The effect is as follows:
Complete ~
Nginx blocks user agents
Sometimes, you need to block some user agents from accessing the site, such as ab,wget,curl, etc., which requires the use of the $http_user_agent variable.
Modify nginx.conf
If ($http_user_agent ~ * (wget | ab)) {return 403;} if ($http_user_agent ~ * lwp::simple | bbbike | wget) {return 403;}
Restart nginx
# / usr/local/nginx-1.7.0/sbin/nginx-s reload's content on "user authentication configuration in Nginx and how to prevent users from using agents to access" ends here. Thank you for your reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.
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.