幾種方式:
1.指令http://www.centos.bz/2011/12/nginx-http-auth-basic/
如果沒有apache的htpasswded,可以使用ploo :http://trac.edgewall.org/export/10890/trunk/contrib/htpasswd.py
使用方法: ./htpasswd.py -b -c pass.txt admin 123456 pass.是為密碼檔案,admintxt使用者名稱,123456是密碼.
2.apache http://jooben.blog.51cto.com/253727/429977
3.命令產生密碼nginx中加入
#auth_basic "Please input your username and password!";
#auth_basic_user_file /usr/local/nginx/conf/engir_pass;