我试图使用Rob 这里描述的技巧在默认情况下在Synology的web服务器上执行“不允许的路径”中的php页面.
其目的是创建不依赖于"初始化_第三党“的包(这个著名的包允许用户在路径(如/volumeX/@appstore/在他们的语法上)中运行php页面)
基本上,Rob建议调用一个使用php-cgi (/usr/local/bin/ php 56-cgi)执行php页面的脚本。
例:调用类似的cgi来执行位于它旁边的页面test.php。
#!/bin/sh
REDIRECT_STATUS=1 export REDIRECT_STATUS
SCRIPT_FILENAME=$(pwd)/test.php export SCRIPT_FILENAME
/usr/bin/php-cgi -d open_basedir=none $SCRIPT_FILENAME 2>&1这很好用。
但是Rob的完整思想是使用.htaccess将对任何php页面的调用重定向到一个通用的cgi脚本。
.htaccess
# Turn on rewrite engine.
RewriteEngine on
# Rewrite existing php files to the router script.
# Apache on the Synology NAS automatically redirects url
# containing '../' to the corresponding real path, before
# the router script is executed, so it's impossible to
# execute system files.
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^(.*\.php)$ router.cgi [PT,L,QSA,NE]router.cgi
#!/bin/sh
# Set redirect_status to 1 to get php cgi working.
REDIRECT_STATUS=1 export REDIRECT_STATUS
# Fix several $_SERVER globals.
PHP_SELF=$SCRIPT_URL export PHP_SELF
SCRIPT_NAME=$SCRIPT_URL export SCRIPT_NAME
# Strip web base from SCRIPT_URL, concat it to parent directory
# and apply realpath to construct absolute path to requested script.
WEB_BASE="/webman/3rdparty"
SCRIPT_FILENAME=$(pwd)/..${SCRIPT_URL:${#WEB_BASE}}
SCRIPT_FILENAME=`realpath $SCRIPT_FILENAME`
export SCRIPT_FILENAME
# Execute the requested PHP file.
/usr/local/bin/php56-cgi -d open_basedir=none $SCRIPT_FILENAME 2>&1我在cgi中添加了跟踪,问题是它从未调用过我的DSM6.1。因此,在我看来,.htaccess似乎没有“启用”。具体来说,对php页面的调用正在下载该文件。
当.htaccess访问位于不允许路径中的php页面时,是否假定在SynologyDSM6.1上使用?如果它应该有效的话,在NAS上会有什么错误的配置?
许多事;分享你在这方面的经验!
这是演示包是由罗伯创建的,用来说明他的文章。
发布于 2018-01-20 18:02:54
我终于解决了这个问题。DSM的最新版本默认使用nginx而不是apache作为web服务器。而nginx是不使用htaccess文件。
https://serverfault.com/questions/892033
复制相似问题