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

nginx的两种配置用户权限访问

2016-02-23 18:38 531 查看
linux中生成密码文件的命令一般有两种
opensslpasswd -crypt passwd之后会生成一个字符串,文件不需要
另一种是
htpasswd -c /etc/filename.db username
这时候会显示用户名输入密码:
当系统显示没有htpasswd命令的时候可以在输入htpasswd后系统显示安装的软件(ubuntu)
最后贴出我自己的nginx的配置作为参考:
server {
listen 9200;
server_name xxxxxxxx;
charset utf8;
auth_basic "secret"; ##使用openssl passwd -crypt passwds加密的时候配置的位置 auth_basic_user_file /etc/nginx/passwords; ##可以不需要文件后缀 location / {
proxy_pass http://xxxxxxxxxx; proxy_redirect default ;
proxy_connect_timeout 60;
proxy_send_timeout 172800;
proxy_read_timeout 6000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_buffering off;
auth_basic "secret"; ##使用htpasswd加密的时候配置的位置
auth_basic_user_file /etc/nginx/passwords.db;
proxy_max_temp_file_size 0;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}

本文出自 “东神要一打五” 博客,谢绝转载!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: