麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁 > 網(wǎng)站 > 建站經(jīng)驗 > 正文

Discuz教程:論壇安全加固

2024-04-25 20:40:22
字體:
供稿:網(wǎng)友

針對discuz的安全加固如下:

1、在nginx入口上對data|images|config|static|source|template 這幾個可以上傳的目錄里的php文件禁止訪問 。(更安全一點就是列出放行的,其他全部禁止。)

location ~* ^/(data|images|config|static|source|template)/.*/.(php|php5)$

{

deny all;

}

按照以上的配置,即使出現(xiàn)上傳漏洞,上傳到了上面配置的幾個目錄php文件,也會報403出錯無法執(zhí)行。更安全的做法是,放行部分,其余全部禁止,例如:

location ~ (index|forum|group|archiver|api|uc_client|uc_server).*/.(php)?$

{

allow all;

fastcgi_pass 127.0.0.1:9000;

fastcgi_index index.php;

include fcgi.conf;

}

不過上面只是一個示例,根目錄下的php文件,我此處并未列全。而且還有一個問題就是,每次有新的版本發(fā)布,如果目錄結(jié)構(gòu)變列或者根目錄新增php文件,都要相應(yīng)的修改nginx 的安全配置。

2、優(yōu)化nginx和php-fpm程序運行用戶。例如,該用戶為www,讓www用戶沒有家目錄,沒有shell,無法登陸。nginx和php-fpm程序是通過root內(nèi)部調(diào)用切換到 www用戶。類似于mysql的啟動。具體增加語句如下:

useradd www -d /dev/null -s /sbin/nologin

如果感覺還不夠安全,可以再利用chroot和sudo等程序,限制www用戶所能訪問的目錄和可以調(diào)用的命令。

3、目錄權(quán)限控制。除了discuz下的data目錄有寫的權(quán)限,取消所有其他目錄的寫權(quán)限。

該步,我看到網(wǎng)上有列出執(zhí)行的shell命令為:

find source -type d -maxdepth 4 -exec chmod 555 {} /;

find api -type d -maxdepth 4 -exec chmod 555 {} /;

find static -type d -maxdepth 4 -exec chmod 555 {} /;

find archive -type d -maxdepth 4 -exec chmod 555 {} /;

find config -type d -maxdepth 4 -exec chmod 555 {} /;

find data -type d -maxdepth 4 -exec chmod 755 {} /;

find template -type d -maxdepth 4 -exec chmod 555 {} /;

find uc_client -type d -maxdepth 4 -exec chmod 555 {} /;

不過按這樣的shell語句執(zhí)行是有警告的,具體所報內(nèi)容如下:

find: warning: you have specified the -maxdepth option after a non-option argument -type, but options are not positional (-maxdepth affects tests specified before it as well as those specified after it). Please specify options before other arguments.

規(guī)范的寫法是:

find source -maxdepth 4 -type d -exec chmod 555 {} /;

find api -maxdepth 4 -type d -exec chmod 555 {} /;

find static -maxdepth 4 -type d -exec chmod 555 {} /;

find archive -maxdepth 4 -type d -exec chmod 555 {} /;

find config -maxdepth 4 -type d -exec chmod 555 {} /;

find data -maxdepth 4 -type d -exec chmod 755 {} /;

find template -maxdepth 4 -type d -exec chmod 555 {} /;

find uc_client -maxdepth 4 -type d -exec chmod 555 {} /;

注:上面的' -maxdepth 4 ' 也是可以取消的。

對目錄設(shè)置完成后,還要對文件配置權(quán)限:

find . -type f -exec chmod 444 {} /;

#設(shè)置論壇目錄的文件只可讀,然后設(shè)置那些需要寫的文件,一般只有data下的文件是可以的。

find data -type f -exec chmod 755 {} /;

#設(shè)置data 文件為755

4、禁止php相關(guān)函數(shù)的調(diào)用及跨站。在php.ini文件中開啟以下兩項

open_basedir = .:/tmp/

disable_functions = passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popep

assthru,stream_socket_server,escapeshellcmd,dll,popen,disk_free_space,checkdnsrr,checkdnsrr,getservbyname,getservbyport,disk_total_space,posix_ctermid,posix_get_last_error,posix

_getcwd, posix_getegid,posix_geteuid,posix_getgid, posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid, posix_getppid,posix_get

pwnam,posix_getpwuid, posix_getrlimit, posix_getsid,posix_getuid,posix_isatty, posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid, posix_setpgid,posix_setsid,posix

_setuid,posix_strerror,posix_times,posix_ttyname,posix_uname

以上主要是對系統(tǒng)層面的調(diào)用函數(shù)全部禁止 。

5、將該KVM機進行隔離。和其他主機無法連接。

該步驟配置是有條件的,在有KVM環(huán)境的條件,可以將各個應(yīng)用之間利用KVM進行隔離。web訪問模式為 物理機iptables nat ——KVM虛擬機 或 web入口——物理機iptables nat ——KVM虛擬機 。

6、數(shù)據(jù)庫控制。

在mysql新建用戶時,一是適當(dāng)分配給用戶所需的權(quán)限,二是要在創(chuàng)建用戶時最好能限定來源IP 。例如:

CREATE USER 'discuz'@'192.168.0.%' IDENTIFIED BY '66ZX811a';

grant select,insert,update,delete,create,index,trigger,create temporary tables on discuz.* to 'discuz'@'192.168.0.%';

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 国产亚洲精品久久午夜玫瑰园 | 欧美性色黄大片www 操碰网 | 97中文字幕第一一一页 | 精品中文字幕在线播放 | 久久成人激情视频 | 成人免费av在线播放 | 久久一区二区三区av | 欧美日韩亚洲另类 | 精精国产xxxx视频在线播放7 | 国产精品白嫩白嫩大学美女 | 黄色大片大毛片 | 精品中文一区 | 92看片淫黄大片欧美看国产片 | 亚洲综合视频网 | 日本黄色免费观看视频 | 九九精品在线观看 | 久久久久久久久久久影视 | 久久精品久| 国产1区视频 | 免费黄色入口 | 91短视频网页版 | 久久精品无码一区二区三区 | 在线男人天堂 | 日韩精品久久久久久 | 在线91观看 | 最近国产中文字幕 | 欧美精品电影一区 | 日日狠狠久久偷偷四色综合免费 | 欧美一区在线观看视频 | chengrenzaixian | 在线观看中文字幕av | 久久免费视频一区二区三区 | 人人舔人人射 | 深夜免费视频 | 欧美日韩电影在线 | 欧美成人精品一区 | 欧美成人小视频 | 国产精品久久久久久久久久久天堂 | 久草视频在线资源 | 国产一级毛片国产 | 日本aaaa片毛片免费观蜜桃 |