PR

This PHP CGI binary was compiled with force-cgi-redirect enabled.

CakePHP の Shell で Socket を使って get するスクリプトがある。それを拡張たスクリプトを動作させてみると以下のメッセージが出た。

Security Alert! The PHP CGI cannot be accessed directly.
This PHP CGI binary was compiled with force-cgi-redirect enabled. This means that a page will only be served up if the REDIRECT_STATUS CGI variable is set, e.g. via an Apache Action directive.

For more information as to why this behaviour exists, see the manual page for CGI security.

For more information about changing this behaviour or re-enabling this webserver, consult the installation file that came with this distribution, or visit the manual page.

スポンサードリンク

なぜだろう。リダイレクトなんかしていないのに。それ以前にまずこのメッセージがスクリプトを実行している側で出ているのか、相手先のサーバーから出力されているのかの切り分けが難しかった。

といっても、getしているのだからたぶん、相手先のサーバーなのだろうと考えた。そして、調べてみると、 php.ini で cgi.force_redirect = 0 を設定するだけで問題は解決した。

ただし、解決はできたものの、Security Alert と言っているそれを解決できたわけでもないので何かしらの対処は必要だと思う。例えば .htaccess でアクセスできる端末を限定するとか。

コメント