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;
}
}
本文出自 “东神要一打五” 博客,谢绝转载!
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;
}
}
本文出自 “东神要一打五” 博客,谢绝转载!
相关文章推荐
- nginx 经典配置教程
- nginx启动、重启、关闭
- nginx访问报错时设置默认提示页
- 利用nginx来屏蔽指定的user_agent的访问
- 在Ubuntu14.04上配置nginx和fastcgi程序
- jdango 部署之nginx+uwsgi
- 安装nginx+lua开发环境
- Linux下安装Nginx详细图解教程
- centos 安装nginx,php-fpm,mysql
- nginx,laravel5.1在ubuntu的部署
- Nginx rewrite规则整理
- ThinkPHP 3.2 在 Nginx 下配置 URL 模式为 REWRITE 模式
- linux 安装 nginx
- nginx增加modsecurity模块
- nginx学习汇总
- 负载均衡配置(基于Nginx)
- 如何配置Nginx+Fastcgi实现控制硬件
- Mac利用brew安装nginx环境
- nginx location语法
- Nginx的安装与使用