From e8d5756467c521620b2e3140c15111f9ffd26bb1 Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Thu, 3 Dec 2015 13:23:37 -0600 Subject: [PATCH] Fix missing path info on nginx. Update nginx documentation to set the PATH_INFO variable. Avoid hacks in index.php if it PATH_INFO is already set for both nginx and apache. --- doc/Installation/Installation-(RHEL-CentOS).md | 1 + html/index.php | 12 +++++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/doc/Installation/Installation-(RHEL-CentOS).md b/doc/Installation/Installation-(RHEL-CentOS).md index 10767378d..ddfdc2cc1 100644 --- a/doc/Installation/Installation-(RHEL-CentOS).md +++ b/doc/Installation/Installation-(RHEL-CentOS).md @@ -186,6 +186,7 @@ server { try_files $uri $uri/ @librenms; } location ~ \.php { + fastcgi_param PATH_INFO $fastcgi_path_info; include fastcgi.conf; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass unix:/var/run/php5-fpm.sock; diff --git a/html/index.php b/html/index.php index aee20f1d7..9a467c13b 100644 --- a/html/index.php +++ b/html/index.php @@ -12,11 +12,13 @@ * */ -if( strstr($_SERVER['SERVER_SOFTWARE'],"nginx") ) { - $_SERVER['PATH_INFO'] = str_replace($_SERVER['PATH_TRANSLATED'].$_SERVER['PHP_SELF'],"",$_SERVER['ORIG_SCRIPT_FILENAME']); -} -else { - $_SERVER['PATH_INFO'] = !empty($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : (!empty($_SERVER['ORIG_PATH_INFO']) ? $_SERVER['ORIG_PATH_INFO'] : ''); +if (empty($_SERVER['PATH_INFO'])) { + if( strstr($_SERVER['SERVER_SOFTWARE'],"nginx") ) { + $_SERVER['PATH_INFO'] = str_replace($_SERVER['PATH_TRANSLATED'].$_SERVER['PHP_SELF'],"",$_SERVER['ORIG_SCRIPT_FILENAME']); + } + else { + $_SERVER['PATH_INFO'] = !empty($_SERVER['ORIG_PATH_INFO']) ? $_SERVER['ORIG_PATH_INFO'] : ''; + } } function logErrors($errno, $errstr, $errfile, $errline) {