惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Cloudbric
Cloudbric
Schneier on Security
Schneier on Security
V2EX - 技术
V2EX - 技术
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
O
OpenAI News
S
Security @ Cisco Blogs
Scott Helme
Scott Helme
Security Archives - TechRepublic
Security Archives - TechRepublic
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
WordPress大学
WordPress大学
云风的 BLOG
云风的 BLOG
T
Threatpost
Hacker News: Ask HN
Hacker News: Ask HN
Microsoft Azure Blog
Microsoft Azure Blog
Know Your Adversary
Know Your Adversary
博客园 - 三生石上(FineUI控件)
A
About on SuperTechFans
Forbes - Security
Forbes - Security
NISL@THU
NISL@THU
Security Latest
Security Latest
G
Google Developers Blog
D
Docker
T
Threat Research - Cisco Blogs
N
Netflix TechBlog - Medium
C
CERT Recently Published Vulnerability Notes
H
Help Net Security
B
Blog
Martin Fowler
Martin Fowler
N
News and Events Feed by Topic
Simon Willison's Weblog
Simon Willison's Weblog
Hacker News - Newest:
Hacker News - Newest: "LLM"
L
Lohrmann on Cybersecurity
Y
Y Combinator Blog
PCI Perspectives
PCI Perspectives
F
Fortinet All Blogs
MyScale Blog
MyScale Blog
Project Zero
Project Zero
爱范儿
爱范儿
Cisco Talos Blog
Cisco Talos Blog
博客园 - 聂微东
Hugging Face - Blog
Hugging Face - Blog
人人都是产品经理
人人都是产品经理
V
Vulnerabilities – Threatpost
P
Proofpoint News Feed
Cyberwarzone
Cyberwarzone
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
TaoSecurity Blog
TaoSecurity Blog
N
News | PayPal Newsroom
Recorded Future
Recorded Future

博客园 - 孤剑

谈谈微信支付曝出的漏洞 阿里云ACE深圳同城会 开始报名 CSS 埋点统计 How to use “svn add” recursively in Linux shell? Java反序列化漏洞执行命令回显实现及Exploit下载 在线测试 ssl 安全性 检测一下你的专业指数:2015年十大测试工具你认识几个? FTP基础知识 FTP port(主动模式) pasv(被动模式) 及如何映射FTP 虚拟机评估——如何确定一个CPU核上部署的虚拟机数量? iptables防火墙原理详解 linux平台下防火墙iptables原理(转) 通过rinetd实现端口转发来访问内网的服务 nmap端口状态解析 每天一个linux命令(53):route命令 49 款开源办公软件 如何关闭Linux里边的selinux ? NMAP 基础教程 Linux下批量修改文件名(rename) 将 LDAP 目录用于 Samba 认证
nginx用户认证配置( Basic HTTP authentication)
孤剑 · 2015-12-29 · via 博客园 - 孤剑

ngx_http_auth_basic_module模块实现让访问着,只有输入正确的用户密码才允许访问web内容。web上的一些内容不想被其他人知道,但是又想让部分人看到。nginx的http auth模块以及Apache http auth都是很好的解决方案。

默认情况下nginx已经安装了ngx_http_auth_basic_module模块,如果不需要这个模块,可以加上 --without-http_auth_basic_module 。

nginx basic auth指令

语法:     auth_basic string | off;
默认值:     auth_basic off;
配置段:     http, server, location, limit_except

默认表示不开启认证,后面如果跟上字符,这些字符会在弹窗中显示。

语法:     auth_basic_user_file file;
默认值:     —
配置段:     http, server, location, limit_except

用户密码文件,文件内容类似如下:

ttlsauser1:password1

ttlsauser2:password2:comment

nginx认证配置实例

1

2

3

4

5

6

7

8

9

10

11

12

13

server{

      

server_name  www.ttlsa.com ttlsa.com;

       

index index.html index.php;

       

root /data/site/www.ttlsa.com;      

               

auth_basic "nginx basic http test for ttlsa.com";

               

auth_basic_user_file conf/htpasswd;

}

备注:一定要注意auth_basic_user_file路径,否则会不厌其烦的出现403。

生成密码

可以使用htpasswd,或者使用openssl

# printf "ttlsa:$(openssl passwd -crypt 123456)\n" >>conf/htpasswd

# cat conf/htpasswd

ttlsa:xyJkVhXGAZ8tM

账号:ttlsa
密码:123456

reload nginx

# /usr/local/nginx-1.5.2/sbin/nginx -s reload

效果如下:

Apache

http_auth_basic_module

完成~