nginx配置访问密码 发表于 2024-09-29 分类于 nginx 安装htpassed工具123yum -y install httpd-tools或者apt install apache2-utils 创建用户名和密码1htpasswd -c /etc/nginx/.htpasswd username 修改nginx配置文件1234567891011server { listen ; server_name localhost; ....... #新增下面两行 auth_basic "Please input password"; #这里是验证时的提示信息 auth_basic_user_file /etc/nginx/.htpasswd; location /{ ....... }}