开启 My Cloud 后台 UI 远程访问

My Cloud 的 UI 后台默认是不支持远程访问的,只能在本地局域网访问。直接在外网访问UI后台会出现:

Forbidden
You don’t have permission to access /UI on this server.

折腾又开始了

1、先准备好 putty、WinSCP,登录 ssh

2、用 WinSCP 或者 putty 编辑 /etc/apache2/sites-available/wdnas-ui.conf,熟悉 vi 的通过 putty 用 vi

<IfModule mod_rewrite.c>
<Directory “${DOCUMENT_ROOT}/UI”>
#${LOCAL_NET}
RewriteEngine On
RewriteBase /UI/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /UI/ [R]
</Directory>
</IfModule>

用 # 注释掉 ${LOCAL_NET},上面我已经注释了。

3、修改 /var/www/rest-api/api/Common/includes/security.inc,306行,需要修改的地方已经用背景色突出来了

/*
 * Returns true if request is from local IP
 */
function isLanRequest() {
 $lanRequest = RequestScope::getInstance()->getLanRequest();
 if(!empty($lanRequest)) {
 return $lanRequest;
 }

 $remoteAddr = $_SERVER['REMOTE_ADDR'];
 \Core\Logger::getInstance()->info('remote addr: ' . $remoteAddr);
 $skipLanCheck = getSkipLanSecurityCheck();
 
 if(strcasecmp($skipLanCheck,"TRUE") == 0) {
 return true;
 }
 if(TRUE || $remoteAddr === '127.0.0.1' || $remoteAddr === 'localhost') {
 RequestScope::getInstance()->setLanRequest(true);
 return true;
 }

4、重启 apache,/etc/init.d/apache2 restart

5、如果还没做端口映射的,去路由器里设置吧,NAT、DMZ…

UI 后台暴漏给外网,风险较大,请谨慎使用。

4 thoughts to “开启 My Cloud 后台 UI 远程访问”

  1. 用了你修改的kodexplorer后,发现可以通过http://IP/kodexplorer/status.php或者http://IP/kodexplorer/tz.php等来直接打开。。。有什么办法能禁止这个?

  2. 兄弟,这样改后,还是不行啊,停在 正在尝试验证身份。。。 这个界面上

回复 kwingart 取消回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注