Apache 使用 mod_auth_basic 模块,给网站增加一个身份认证代理
创始人
2024-06-03 10:55:56
0

以 phpMyAdmin 网站为例
将 phpMyAdmin 隐藏在认证代理后面,这样用户在向 phpMyAdmin 提供 MySQL 凭证之前就需要进行认证

官方文档
AuthBasicProvider Directive

步骤

  1. 使用 htpasswd 创建密码文件

    htpasswd -c /usr/share/phpmyadmin/passwd test01

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

    cat /usr/share/phpmyadmin/passwd

     test01:$apr1$SUzFEIsh$ZYz1pDpxTuaqxORN8oYem0
    

    如果需要修改密码,先使用 htpasswd -D 删除,再使用 htpasswd -b修改

    htpasswd -D /usr/share/phpmyadmin/passwd test01

     Deleting password for user test01
    

    htpasswd -b /usr/share/phpmyadmin/passwd test01 123456

     Adding password for user test01
    
  2. 配置需要代理的网站

    cd /etc/httpd/conf.d
    cat phpmyadmin.conf

    ## Possible values for the Options directive are "None", "All",# or any combination of:#   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews## Note that "MultiViews" must be named *explicitly* --- "Options All"# doesn't give it to you.## The Options directive is both complicated and important.  Please see# http://httpd.apache.org/docs/2.4/mod/core.html#options# for more information.## wzh 20230313Options Indexes FollowSymLinks# Options -Indexes +FollowSymLinks## AllowOverride controls what directives may be placed in .htaccess files.# It can be "All", "None", or any combination of the keywords:#   Options FileInfo AuthConfig Limit## wzh 20230313#AllowOverride None#AllowOverride All## Controls who can get stuff from this server.##  Require all granted# wzh 20230314AuthType BasicAuthName "Restricted Access"AuthUserFile /usr/share/phpmyadmin/passwdRequire valid-userAlias /phpadmin /var/www/html/phpmyadmin
    
  3. 重启 apache 服务
    systemctl restart httpd

    ubuntu 系统
    systemctl status apache2

  4. 测试 http://192.168.0.113/phpmyadmin
    在这里插入图片描述

相关内容

热门资讯

监控摄像头接入GB28181平... 流程简介将监控摄像头的视频在网站和APP中直播,要解决的几个问题是:1&...
Windows10添加群晖磁盘... 在使用群晖NAS时,我们需要通过本地映射的方式把NAS映射成本地的一块磁盘使用。 通过...
protocol buffer... 目录 目录 什么是protocol buffer 1.protobuf 1.1安装  1.2使用...
Fluent中创建监测点 1 概述某些仿真问题,需要创建监测点,用于获取空间定点的数据࿰...
educoder数据结构与算法...                                                   ...
MySQL下载和安装(Wind... 前言:刚换了一台电脑,里面所有东西都需要重新配置,习惯了所...
MFC文件操作  MFC提供了一个文件操作的基类CFile,这个类提供了一个没有缓存的二进制格式的磁盘...
在Word、WPS中插入AxM... 引言 我最近需要写一些文章,在排版时发现AxMath插入的公式竟然会导致行间距异常&#...
有效的括号 一、题目 给定一个只包括 '(',')','{','}'...
【Ctfer训练计划】——(三... 作者名:Demo不是emo  主页面链接:主页传送门 创作初心ÿ...