知識點022-nginx 的rewrite 僞靜態與設置網頁登錄密碼

 1.rewrite的書寫html

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網頁上面去nginx

2.訪問認證web

獲取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;
相關文章
相關標籤/搜索