配置nginx密码访问

2020-06-19  本文已影响0人  愤愤的有痣青年

有时候有些接口需要配置权限访问,但是有不方便直接在项目中添加,此时可以使用nginx做代理,然后在nginx中做权限验证.

New password: 
Re-type new password: 
Adding password for user you_user_name

然后就会生成/etc/nginx/htpasswd文件,如果ubuntu下提示
The program 'htpasswd' is currently not installed. To run 'htpasswd' please ask your administrator to install the package 'apache2-utils'.可以运行sudo apt-get install apache2-utils -y安装依赖库

   location / {
        proxy_pass http://10.0.0.102:5601$request_uri;
        #加上下面两行内容:
        auth_basic "登陆验证";
        auth_basic_user_file /etc/nginx/htpasswd;   
    }
上一篇 下一篇

猜你喜欢

热点阅读