日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > php >内容正文

php

php 401认证,给phpMyAdmin增加401加密认证

發布時間:2023/12/16 php 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 php 401认证,给phpMyAdmin增加401加密认证 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

phpMyAdmin是一個以PHP為基礎,以Web-Base方式架構在網站主機上的MySQL的數據庫管理工具,讓管理者可用Web接口管理MySQL數據庫。由于phpMyAdmin漏洞比較多,所以我們除了要更改默認路徑外還要設置401驗證,提高安全性,不過還是不建議安裝phpMyAdmin,畢竟漏洞確實多。

安裝apache htpasswd命令

yum -y install httpd-tools

1

yum-yinstallhttpd-tools

首先通過htpasswd生成401的帳號和密碼,此處采用SHA加密

htpasswd -cs /usr/local/nginx/conf/401htpasswd whsir #whsir為401用戶名

1

htpasswd-cs/usr/local/nginx/conf/401htpasswdwhsir#whsir為401用戶名

將401添加到php的location中

location ~ \.php$ {

auth_basic "this is 401whsir";

auth_basic_user_file /usr/local/nginx/conf/401htpasswd;

fastcgi_pass unix:/tmp/php-cgi.sock;

fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

include fastcgi.conf;

}

1

2

3

4

5

6

7

8

location~\.php${

auth_basic"this is 401whsir";

auth_basic_user_file/usr/local/nginx/conf/401htpasswd;

fastcgi_passunix:/tmp/php-cgi.sock;

fastcgi_indexindex.php;

fastcgi_paramSCRIPT_FILENAME$document_root$fastcgi_script_name;

includefastcgi.conf;

}

檢查配置

nginx -t

1

nginx-t

重啟nginx

service nginx restart

1

servicenginxrestart

假設phpmyadmin地址是http://10.10.10:888/phpmyadmin/

此時訪問http://10.10.10:888/phpmyadmin/就會跳出401了

如果按下面這種方法配置的話,使用絕對路徑是可以繞過401的

location /

{

auth_basic "this is 401whsir";

auth_basic_user_file /usr/local/nginx/conf/401htpasswd;

}

1

2

3

4

5

location/

{

auth_basic"this is 401whsir";

auth_basic_user_file/usr/local/nginx/conf/401htpasswd;

}

舉例:正常訪問http://10.10.10:888/phpmyadmin/跳出401

如果訪問http://10.10.10:888/phpmyadmin/index.php,取消多次是可以繞過401的,這里假設目錄下有index.php文件

給帝國后臺增加401認證,示例如下:

location /e/admin/

{

auth_basic "401";

auth_basic_user_file /usr/local/nginx/conf/401htpasswd;

}

location ~ /e/admin/.*\.php$

{

auth_basic "401";

auth_basic_user_file /usr/local/nginx/conf/401htpasswd;

try_files $uri =404;

fastcgi_pass unix:/tmp/php-cgi.sock;

fastcgi_index index.php;

include fastcgi.conf;

}

1

2

3

4

5

6

7

8

9

10

11

12

13

14

location/e/admin/

{

auth_basic"401";

auth_basic_user_file/usr/local/nginx/conf/401htpasswd;

}

location~/e/admin/.*\.php$

{

auth_basic"401";

auth_basic_user_file/usr/local/nginx/conf/401htpasswd;

try_files$uri=404;

fastcgi_passunix:/tmp/php-cgi.sock;

fastcgi_indexindex.php;

includefastcgi.conf;

}

注意:上面配置要放在location ~ [^/]\.php(/|$)的前面

htpasswd命令常用的幾個選項:

-c:創建一個加密文件

-p:不對密碼進行進行加密,即明文密碼

-m:采用MD5算法對密碼進行加密

htpasswd -c -s /usr/local/nginx/conf/401 whsir

-d:采用CRYPT算法對密碼進行加密

htpasswd -c -s /usr/local/nginx/conf/401 whsir

-s:采用SHA算法對密碼進行加密

htpasswd -c -s /usr/local/nginx/conf/401 whsir #用戶名whsir

-b:在命令行中一并輸入用戶名和密碼而不是根據提示輸入密碼

htpasswd -c -b /usr/local/nginx/conf/401 whsir 123 #用戶名whsir,密碼123

~微信打賞~

分享到:

總結

以上是生活随笔為你收集整理的php 401认证,给phpMyAdmin增加401加密认证的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。