On Fri, Aug 2, 2024 at 12:18 AM Yann Ylavic <[email protected]> wrote:
>
> So we probably should keep encoding r->filename with ProxyPass, and
> come back to my previous patch which skipped it only for SetHandler?
> Possibly FCGI_MAY_BE_FPM() only too because for "ProxyFCGIBackendType
> GENERIC" we don't send the "proxy:scheme://host" part and
> SCRIPT_NAME/FILENAME are supposed to be the real decoded paths?
So I did this in r1919629.
>
> But it's going to be an endless issue if we can't fix or align
> ProxyPass and SetHandler because of workarounds there, we have to
> remain bug compatible..
For this how about this attached patch?
With it I can get the correct env vars (I think), and since we'd not
send a "proxy:" SCRIPT_FILENAME anymore, php-fpm would not flag
"apache_was_there" and work straight with the raw vars? I'm probably
having a sweet dream :)
Just in case..
Index: modules/proxy/mod_proxy_fcgi.c
===================================================================
--- modules/proxy/mod_proxy_fcgi.c (revision 1919623)
+++ modules/proxy/mod_proxy_fcgi.c (working copy)
@@ -29,6 +29,7 @@ typedef struct {
typedef struct {
int need_dirwalk;
+ char *filename;
} fcgi_req_config_t;
/* We will assume FPM, but still differentiate */
@@ -119,8 +142,10 @@ static int proxy_fcgi_canon(request_rec *r, char *
rconf = apr_pcalloc(r->pool, sizeof(fcgi_req_config_t));
ap_set_module_config(r->request_config, &proxy_fcgi_module, rconf);
}
+ rconf->filename = apr_pstrcat(r->pool, "/", url, NULL);
- if (NULL != (pathinfo_type = apr_table_get(r->subprocess_env, "proxy-fcgi-pathinfo"))) {
+ pathinfo_type = apr_table_get(r->subprocess_env, "proxy-fcgi-pathinfo");
+ if (pathinfo_type) {
/* It has to be on disk for this to work */
if (!strcasecmp(pathinfo_type, "full")) {
rconf->need_dirwalk = 1;
@@ -159,6 +184,9 @@ static int proxy_fcgi_canon(request_rec *r, char *
"set r->path_info to %s", r->path_info);
}
}
+ else if (FCGI_MAY_BE_FPM(dconf) && !from_handler) {
+ rconf->need_dirwalk = 1;
+ }
return OK;
}
@@ -337,12 +365,17 @@ static apr_status_t send_environment(proxy_conn_re
int next_elem, starting_elem;
fcgi_req_config_t *rconf = ap_get_module_config(r->request_config, &proxy_fcgi_module);
fcgi_dirconf_t *dconf = ap_get_module_config(r->per_dir_config, &proxy_fcgi_module);
+ char *saved_filename = r->filename;
- if (rconf && rconf->need_dirwalk) {
- char *saved_filename = r->filename;
- r->filename = r->uri;
- ap_directory_walk(r);
- r->filename = saved_filename;
+ if (rconf) {
+ if (rconf->filename) {
+ r->filename = rconf->filename;
+ }
+ if (rconf->need_dirwalk) {
+ r->proxyreq = PROXYREQ_NONE;
+ ap_core_translate(r);
+ ap_directory_walk(r);
+ }
}
/* Strip proxy: prefixes */
@@ -379,6 +412,9 @@ static apr_status_t send_environment(proxy_conn_re
ap_add_common_vars(r);
ap_add_cgi_vars(r);
+ r->filename = saved_filename;
+ r->proxyreq = PROXYREQ_REVERSE;
+
/* XXX are there any FastCGI specific env vars we need to send? */
/* Give admins final option to fine-tune env vars */