LNMP配置——Nginx配置 —— 用户认证
一、配置
再来创建一个新的虚拟主机
#cd /usr/local/nginx/conf/vhost
#vi test.com.conf
写入:
server
{
listen 80;
server_name test.com;
index index.html index.htm index.php;
root /data/nginx/test.com;
location /
{
auth_basic "Auth";
//打开认证
auth_basic_user_file /usr/local/nginx/conf/htpasswd;
//指定用户密码文件
}
}
#yum install -y httpd
//安装httpd,也可以使用之前编译安装的Apache2.4
下面创建和更新用于基本认证的用户认证密码文件
#htpasswd -c /usr/local/nginx/conf/htpasswd dongying
new password:
re-type new password:
Adding password for user dongying
# /usr/local/nginx/sbin/nginx -t

#/usr/local/nginx/sbin/nginx -s reload
#mkdir /data/nginx/test.com
#echo "test.com" > /data/nginx/test.com/index.html
二、测试
#curl -I -x127.0.0.1:80 test.com

状态码401
# curl -udongying:dongying -x127.0.0.1:80 test.com

[root@localhost vhost]# systemctl stop firewalld
[root@localhost vhost]# setenforce 0
关闭防火墙
编辑C:\Windows\System32\drivers\etc\hosts文件,添加映射
终端的IP test.com ifconfig 查看
打开浏览器访问test.com


LNMP配置——Nginx配置 —— 用户认证的更多相关文章
- nginx 添加用户认证
nginx 添加用户认证 nginx 配置文件添加: 配置代理添加用户认证:server { listen ; server_name localhost; location ...
- Nginx网站用户认证
一.Nginx网站用户认证 用户认证:用户访问网页时需要输入一个用户名和密码才能打开网页. nginx的默认网页时安装目录下的html/index.html,配置文件在安装目录下的conf目录中的ng ...
- Linux服务器---配置apache支持用户认证
Apache支持用户认证 为了服务器的安全,通常用户在请求访问某个文件夹的时候,Apache可以要求用户输入有效的用户名和登录密码 1.创建一个测试目录 [root@localhost cgi-bin ...
- YAPI工具配置LDAP统一用户认证
背景:因为搭建了LDAP,因此希望将所有配置库或工具都使用LDAP进行统一用户认证,YAPI是其中一个. YAPI:使用docker-compose进行了安装,具体安装步骤自行百度. LDAP:使用d ...
- lnmp下 nginx 配置虚拟主机
<一.参考> 这里以配置2个站点(2个域名)为例,n 个站点可以相应增加调整,假设: IP地址: 202.55.1.100 域名1 example1.com 放在 /www/example ...
- 免费SSL-HTTS 申请与配置 NGINX配置
Let's Encrypt是很火的一个免费SSL证书发行项目,自动化发行证书,证书有90天的有效期.适合个人使用或者临时使用,不用再忍受自签发证书不受浏览器信赖的提示.Let's Encrypt已经发 ...
- nginx访问控制用户认证两种方式
一.用户认证1.首先需要用http来生成密码文件即安装apache :yum install -y httpd 生成密码文件:htpasswd -c /usr/local/nginx/conf/htp ...
- 三、Nginx设置用户认证
要求:通过nginx服务端配置实现以下目标 访问web页面需要进行用户认证. 用户名为:tom,密码:123456 操作步骤, 更改配置文件 [root@client ~]# vim /usr/loc ...
- lnmp之Nginx配置https加密访问
配置lnmp之Nginx网站支持https加密访问 注: 1. 这里拿购买的(pxsnx.pxjy.com)证书来做样例 证书文件共有三个---> (pxsnxg.pxjy.com_ca.crt ...
随机推荐
- Kubernets二进制安装(5)之私有仓库harbor搭建
在IP地址为192.168.80.50,机器名为mfyxw50上搭建私有仓库harbor harbor下载地址: harbor下载连接地址:https://github.com/goharbor/ha ...
- flex 布局占位符
flex 布局占位符 空 span bug .popover-custom-class .system-guide-container .buttons-box { display: flex; fl ...
- v-for & for...in vs for...of
v-for & for...in vs for...of for..in vs for...of for (const key in object) { if (Object.hasOwnPr ...
- js sort map by key
js sort map by key Map map to array // Array.from() Object let obj = {}; for(let key of Object.keys( ...
- Immutable.js 实现原理
Immutable.js 实现原理 Immutable collections for JavaScript v4.0.0-rc.12 released on Oct 31, 2018 https:/ ...
- no need jQuery anymore & You don't need jQuery anymore!
no need jQuery anymore & You don't need jQuery anymore! "use strict"; /** * * @author ...
- how to write an ebook that can support published by format PDF, Epub, Mobi and so on
how to write an ebook that can support published by format PDF, Epub, Mobi and so on 如何写一本自己的电子书,支持各 ...
- HTML5 image rotate effect
HTML5 image rotate effect HTML5 实现旋转拨号键盘 简单的html中js实现图片中心旋转 https://download.csdn.net/download/q3168 ...
- 万链互联时代,NGK DeFi项目如何在牛市中崭露头角!
众所周知,中心化交易所存在技术风险.道德风险与法律风险.去中心化交易所像是NGK以其匿名性.安全性.私钥独立掌控的特点,弥补了中心化交易所的不足,我们看到Uniswap日成交量均超过1亿美元,甚至接近 ...
- hadoop环境搭建:高可用
目录 1.硬件配置 2.软件版本 3.准备工作 3.1.配置网络环境 3.2.安装JDK 3.3.安装ZOOKEEPER 4.安装Hadoop 5.启动 6.问题 7.配置文件 1.硬件配置 采用3台 ...