找回密码
 立即注册
查看: 108|回复: 0

nginx为网站某个目录添加单独的认证

[复制链接]

681

主题

0

回帖

681

积分

00话痨hs000

积分
681
发表于 2023-6-18 11:59:59 | 显示全部楼层 |阅读模式
  1.     server {        listen       443 ssl;        server_name  book.com;        ssl_certificate      cert.pem;        ssl_certificate_key  cert.key;        ssl_session_cache    shared:SSL:1m;        ssl_session_timeout  5m;        ssl_ciphers  HIGH:!aNULL:!MD5;        ssl_prefer_server_ciphers  on;        location / {            root C:\website\book;            index  index.htm index.html index.php;                    }         location /加密书籍 {          # 基本验证         root C:\website\book;        index  index.htm index.html index.php;        auth_basic "nginx basic auth";        auth_basic_user_file C:\website\auth.txt; }    }
复制代码
密码文件生成网址
[color=var(--external-link)]https://tool.oschina.net/htpasswd
选择方式md5
auth.txt认证文件格式
  1. username:MD5password
复制代码
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|翻墙党

GMT+8, 2026-9-26 07:52 , Processed in 0.075473 second(s), 23 queries .

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表