InsideDarkWeb.com

Passing REQUEST_URI php-fm after a rewrite in Apache

We are trying to migrate an installation to Apache event engine replacing mod_php for PHP-FPM.
We have a large an complex list of rewrites performed by apache from old urls and also to produce SEO friendly URLs as in:

#Ej: /holidays/costa-del-sol/nombre-99.html
RewriteRule ^/holidays/([^/])/([^/])-([d]+).html$ /scripts/pack.php?package=$3&lang=eng [QSA,P,E=notAllowedParams:package-region-regionname-lang,E=ORIG_URI:/$1]

But furthermore, our PHP also confirms that the clients used URL is valid and otherwise performs a redirect. For this, we evaluate the $SERVER REQUEST_URI variable, but this variable is now incorrectly set to the second "script" url instead of the source.

This is… Apache receives a request for URL X, rewrites (no 301) internally to a Y address. With mod_php that is transparent to PHP but now as we "proxy" to PHP-FM the Y script is called (so the rewrite is executed) but we can’t find a way to force REQUEST_URI value to be maintained and received by PHP.

Our Apache config for PHP-FPM

<FilesMatch .php$>
    # 2.4.10+ can proxy to unix socket
    # SetHandler "proxy:unix:/var/run/php5-fpm.sock|fcgi://localhost/"
    # Else we can just use a tcp socket:
    SetHandler "proxy:fcgi://127.0.0.1:9001"
</FilesMatch>
ProxyPassMatch ^/(..php(/.)?)$ fcgi://127.0.0.1:9001/${GIS_JOSE}/www/$1 enablereuse=on

We’ve tried various options to retain that value without success:

ProxyPreserveHost On
ProxyRequests Off
ProxyFCGISetEnvIf "true" REQUEST_URI "%{reqenv:REQUEST_URI}"
RewriteOptions InheritBefore

Our doubt is if it’s not possible or we are missing something regarding the order of execution.

Server Fault Asked by luison on November 22, 2021

0 Answers

Add your own answers!

Related Questions

HP DL380p G8 Populating the RAM

0  Asked on December 24, 2020 by khizer-hussain

   

Accessing servers through hostname now requires FQDN?

0  Asked on December 24, 2020 by dpsspatial

   

Outlook SSL Error after New Certificate Installation

6  Asked on December 24, 2020 by clay-powell

     

Is aws-iam-authenticator still needed with EKS?

1  Asked on December 22, 2020 by giovanni-tirloni

   

I can’t start connection with WebSockets in EC2

0  Asked on December 21, 2020 by paula-silva

       

Ask a Question

Get help from others!

© 2021 InsideDarkWeb.com. All rights reserved.