2024 dokuwiki data directory is not properly secured

2024 dokuwiki data directory is not properly secured

許久沒有登入dokuwiki管理後台,登入之後出現下列錯誤
It seems your data directory is not properly secured. Please read
http://www.dokuwiki.org/security




經檢查是Apache的AllowOverride的設定沒有正確導致的錯誤訊息。

os:ubuntu 20.04 LTS
Apache:2.4.41
閱讀全文: 2024 dokuwiki data directory is not properly secured

dokuwiki錯誤訊息

會出現It seems your data directory is not properly secured. Please read
http://www.dokuwiki.org/security

主要是因DokuWiki 將配置和頁面資料儲存在檔案中。這些文件不應該直接從網路存取。
dokuwiki 目錄中會包含一組.htaccess文件,這些文件會告訴 Apache Web 伺服器拒絕存取某些目錄。
而會出現這樣的錯誤訊息,主要原因是.htaccess沒有啟用的關係

先確認.htaccess是否啟用。
打開瀏覽器檢查網站上的dokuwiki.txt是否能夠看到內容
http://yourserver.com/data/pages/wiki/dokuwiki.txt
如果能夠看到內容,恭喜您,.htaccess沒有啟用

解決方式

Non-VirtualHost

如果沒有啟用VirtualHost
切換到/etc/apache2/sites-available/

cd /etc/apache2/sites-available

打開000-default.conf檔案

sudo vi 000-default.conf

新增下列內容

      <Directory /var/www/html>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
      </Directory>

修改完畢後重新啟用 Apache

sudo service apache2 restart

VirtualHost

如果有啟用VirtualHost
切換到/etc/apache2/sites-available/
確認dokuwiki VirtualHost是哪一個檔案

cd /etc/apache2/sites-available
ls -al

範例中dokuwiki VirtualHost 檔案為dokuwiki.conf
編輯dokuwiki.conf

sudo vi dokuwiki.conf

確認下列內容

將AllowOverride none 改為AllowOverride All

<Directory /var/www/html/dowuwiki>
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>
</VirtualHost>

修改完畢後重新啟用 Apache

sudo service apache2 restart

如果dokuwiki沒有.htaccess可以將.htaccess.dist變更為.htaccess

sudo cp .htaccess.dist .htaccess

調整檔案擁有者

sudo chown www-data:www-data .htaccess

驗證

打開瀏覽器檢查網站上的dokuwiki.txt是否能夠看到內容
http://yourserver.com/data/pages/wiki/dokuwiki.txt

http://yourserver.com/data/pages/wiki/dokuwiki.txt

正常應該會出現Forbidden,而不是dokuwiki.txt的內容

Forbidden
You don't have permission to access this resource.

回到管理選單又出現相同的錯誤,別擔心清理瀏覽器Cache之後,就不會看到錯誤訊息了,以上設定希望有幫助到您。

延伸閱讀

9,031 Views