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

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了nginx的两种配置用户权限访问相关的知识,希望对你有一定的参考价值。

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;

        }

}




本文出自 “东神要一打五” 博客,谢绝转载!

以上是关于nginx的两种配置用户权限访问的主要内容,如果未能解决你的问题,请参考以下文章

Nginx部署静态页面及引用图片有效访问的两种方式

nginx中设置限制指定用户或IP组访问权限

开启电脑的管理员权限的两种方法

nginx配置虚拟主机的两种方式

centos给普通用户提权的两种方式

Nginx缓存的两种方式