博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
nginx配置用户认证
阅读量:6885 次
发布时间:2019-06-27

本文共 1254 字,大约阅读时间需要 4 分钟。

hot3.png

[root@wjh2 ~]# htpasswd -c /usr/local/nginx/conf/.htpasswd test

#用apache下的hptasswd命令生成密码,apaceh有详解#

New password:

Re-type new password:

Adding password for user test

[root@wjh2 ~]# vi /usr/local/nginx/conf/vhosts/discuz.conf #打开虚拟主机配置文件#

加入以下配置:

server

{

listen 80; #监听端口#

server_name www.123.com ; #访问域名#

index index.html index.htm index.php;

root /discuz/www; #网站根目录#

#用户认证

location ~ .*admin\.php$ { #匹配admin.php访问是discuz管理后台#location / 匹配全站 location /aming/ 匹配目录

auth_basic "qing zhu yi an quang"; #提示信息,可随便自定义#

auth_basic_user_file /usr/local/nginx/conf/.htpasswd; #指定创建用户密码路径#

include fastcgi_params;

fastcgi_pass 127.0.0.1:9000;

fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME /discuz/www$fastcgi_script_name;

}

location ~ \.php$ {

include fastcgi_params;

#fastcgi_pass unix:/tmp/php-fcgi.sock

fastcgi_pass 127.0.0.1:9000;

fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME /discuz/www$fastcgi_script_name;

}

}

[root@wjh2 www]# service nginx configtest #检查配置文件有没有错误#

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

[root@wjh2 www]# service nginx reload #重新加载配置文件#

重新载入 Nginx: [确定]

095957_BISE_3760338.png

转载于:https://my.oschina.net/u/3760338/blog/1601498

你可能感兴趣的文章
linux配置网卡
查看>>
正则表达式语法
查看>>
013、Dockerfile构建镜像(2019-01-02 周三)
查看>>
c# mvc如何获取xml文件
查看>>
mongodb Java(八)
查看>>
JavaScript随机数
查看>>
ASP.NET验证控件——RequiredFieldValidator
查看>>
strstr
查看>>
MySQL 条件 select case 的实现(解决 零 做分母的问题 )
查看>>
openNebula rgister img instance vms error collections
查看>>
error Infos
查看>>
PL/sql配置相关
查看>>
Linux 查询服务数据
查看>>
【Luogu 2014】选课
查看>>
CSS 的介绍
查看>>
Latex自定义文档纸张大小
查看>>
2018QBXT刷题游记(23)
查看>>
函数递归
查看>>
android框架Java API接口总注释/**@hide*/和internal API
查看>>
20175318 2018-2019-2 《Java程序设计》第七周学习总结
查看>>