Hello!
I had to leave one hosting where I wanted to use Cherokee server behind nginx used as reverse-proxy due to 500 errors.
Then I moved to my old hosting which also uses nginx as reverse-proxy and Cherokee failed by having port number appended to the URl, like
http://domain.com:port/.
Support told me it’s, probably, due to Cherokee not having support for
X-Forwarded-For which is generated by reverse proxy server.
I was told to try with Lighty, but I experience the same issue despite server’s support for
X-Forwarded-For.
Now, I think the problem is with MODx which seems not to be suitable to be run behind reverse-proxy and, in this case, lighty which is one of supported servers according to
http://rtfm.modx.com/display/revolution20/Server+Requirements
Here is the snippet which handles URL stuff:
if (!defined('MODX_HTTP_HOST')) {
if(defined('PHP_SAPI') && (PHP_SAPI == "cli" || PHP_SAPI == "embed")) {
$http_host='gour-nitai.com:62845';
define('MODX_HTTP_HOST', $http_host);
} else {
$http_host= $_SERVER['HTTP_HOST'];
if ($_SERVER['SERVER_PORT'] != 80) {
$http_host= str_replace(':' . $_SERVER['SERVER_PORT'], '', $http_host); // remove port from HTTP_HOST
}
$http_host .= ($_SERVER['SERVER_PORT'] == 80 || $isSecureRequest) ? '' : ':' . $_SERVER['SERVER_PORT'];
define('MODX_HTTP_HOST', $http_host);
}
}
It looks, to me, a bit strange to test $_SERVER[’SERVER_PORT’ twice and it looks it does not handle properly reverse-proxy case where server is indeed running on port != 80.
Any hint or solution how to use MODx behind reverse-proxy?