Skip to content

Commit db537b1

Browse files
committed
Fix SetHandler proxy:fcgi:// incompatibilities
Apache 2.4.10+ will allow the following: ``` <FilesMatch \.php$> SetHandler proxy:fcgi://localhost:9000 </FilesMatch> ``` This is much easier than using `ProxyPassMatch` (which prevents rewriting and other stuff) and rewrites (which are a bag of hurt because when combined with user-land `.htaccess` rewrites, there's always rewrite loops, prefix breakage etc (I've tried, for weeks). It's basically the future of using Apache (via `mod_proxy_fcgi`) together with PHP-FPM. It's also available for older versions as a standalone module, very easy to install: https://gist.github.com/progandy/6ed4eeea60f6277c3e39 However, the two bits of code this commit deletes interfere with that. They both cover CGI-only mode and were copied from that SAPI into the FPM source. See e.g. https://bugs.php.net/bug.php?id=47042 The first deleted part mangled `SCRIPT_NAME` if something like ``` RewriteCond %{REQUEST_FILENAME} !-f RewriteRule (.*) index.php/$1 [L] ``` is used (i.e. rewriting to `PATH_INFO`. The second part drops `PATH_INFO` if there was a `REDIRECT_URL` (with CGI mode, `SCRIPT_FILENAME` in Apache is the path to the PHP binary, and `PATH_INFO` contains the name of the script to run). Clearly, neither applies in the case of FPM, so both are safe to delete.
1 parent 356c442 commit db537b1

File tree

1 file changed

+1
-24
lines changed

1 file changed

+1
-24
lines changed

sapi/fpm/fpm/fpm_main.c

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1142,19 +1142,6 @@ static void init_request_info(TSRMLS_D)
11421142
TRANSLATE_SLASHES(env_document_root);
11431143
}
11441144

1145-
if (env_path_translated != NULL && env_redirect_url != NULL &&
1146-
env_path_translated != script_path_translated &&
1147-
strcmp(env_path_translated, script_path_translated) != 0) {
1148-
/*
1149-
* pretty much apache specific. If we have a redirect_url
1150-
* then our script_filename and script_name point to the
1151-
* php executable
1152-
*/
1153-
script_path_translated = env_path_translated;
1154-
/* we correct SCRIPT_NAME now in case we don't have PATH_INFO */
1155-
env_script_name = env_redirect_url;
1156-
}
1157-
11581145
#ifdef __riscos__
11591146
/* Convert path to unix format*/
11601147
__riscosify_control |= __RISCOSIFY_DONT_CHECK_DIR;
@@ -1323,7 +1310,7 @@ static void init_request_info(TSRMLS_D)
13231310
efree(pt);
13241311
}
13251312
} else {
1326-
/* make sure path_info/translated are empty */
1313+
/* make sure original values are remembered in ORIG_ copies if we've changed them */
13271314
if (!orig_script_filename ||
13281315
(script_path_translated != orig_script_filename &&
13291316
strcmp(script_path_translated, orig_script_filename) != 0)) {
@@ -1332,16 +1319,6 @@ static void init_request_info(TSRMLS_D)
13321319
}
13331320
script_path_translated = _sapi_cgibin_putenv("SCRIPT_FILENAME", script_path_translated TSRMLS_CC);
13341321
}
1335-
if (env_redirect_url) {
1336-
if (orig_path_info) {
1337-
_sapi_cgibin_putenv("ORIG_PATH_INFO", orig_path_info TSRMLS_CC);
1338-
_sapi_cgibin_putenv("PATH_INFO", NULL TSRMLS_CC);
1339-
}
1340-
if (orig_path_translated) {
1341-
_sapi_cgibin_putenv("ORIG_PATH_TRANSLATED", orig_path_translated TSRMLS_CC);
1342-
_sapi_cgibin_putenv("PATH_TRANSLATED", NULL TSRMLS_CC);
1343-
}
1344-
}
13451322
if (env_script_name != orig_script_name) {
13461323
if (orig_script_name) {
13471324
_sapi_cgibin_putenv("ORIG_SCRIPT_NAME", orig_script_name TSRMLS_CC);

0 commit comments

Comments
 (0)