您的位置:首页 > 运维架构 > Nginx

知识点022-nginx 的rewrite 伪静态与设置网页登陆密码

2018-02-26 00:00 423 查看
1.rewrite的书写

server {
listen       80;
server_name  www.jimmy.com;
location / {
root   html/www;
index  index.html index.htm;
}
location =/ {
rewrite ^/(.*) http://home.51cto.com/$1 permanent;
}
access_log   logs/www_access.log   main;

}

直接跳转到51.cto网页上面去

2.访问认证

获取htpasswd设置账号密码命令
yum install httpd -y
which htpaaswd
[root@web01 ~]# which htpasswd
/usr/bin/htpasswd
[root@web01 ~]#
创建账号密码
htpasswd -bc /application/nginx/conf/htpasswd carlton 123456
[root@web01 ~]# htpasswd -bc /application/nginx/conf/htpasswd carlton 123456
Adding password for user jimmy
[root@web01 ~]#
在www.conf配置文件中添加语句
auth_basic				"This is carlton webhome";
auth_basic_user_file    /application/nginx/conf/htpasswd;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: